http://www.perlmonks.org?node_id=161688

TheHobbit has asked for the wisdom of the Perl Monks concerning the following question:

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?

Cheers
Leo TheHobbit