in reply to Finding all substrings
sub substrings { my $string = shift; my @result = (); my $strlen = length $string; foreach my $length (1..$strlen) { foreach my $offset (0..$strlen-$length) { push @result, substr($string,$offset,$length); } } return @result; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Finding all substrings
by broquaint (Abbot) on Apr 24, 2002 at 18:12 UTC | |
by samtregar (Abbot) on Apr 24, 2002 at 18:26 UTC | |
by erikharrison (Deacon) on Apr 24, 2002 at 18:29 UTC | |
|
Re: Re: Finding all substrings
by giulienk (Curate) on Apr 24, 2002 at 18:08 UTC | |
by suaveant (Parson) on Apr 24, 2002 at 18:13 UTC |