on-internet
← Community

Getting every possible substring

Stack Overflow ·

I would like to generate every possible consecutive substring of a string, including the end of the word/beginning from the word (cyclic) letter combinations. I've found an example in Python, but the only language I know is Perl (and barely, I'm a beginner). I would appreciate it a lot if someone can help me translating the code to Perl or to help me find a solution in Perl. The Python code is the following: aa='ABCD' F=[] B=[] for j in range(1,len(aa)+1,1): for i in range(0,len(aa),1): A=str.split(((aa*j)[i:i+j])) B=B+A C=(B[0:len(aa)*len(aa)-len(aa)+1]) It gives you: C=['A', 'B', 'C', 'D', '

Comments

Sign in or sign up to comment and upvote.

No comments yet.