Hi monks
I need to find the list of substing of a given string. The following sub does the job
sub substrings { my $string = shift; my @result = (); foreach my $length (1..length($string)) { foreach my $offset (0..length($string)-$length) { push @result,substr($string,$offset,$length); } } return @result; }
but I was wondering... is there a more efficent way to get this set?
CheersIn reply to Finding all substrings by TheHobbit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |