in reply to Re: List of substrings
in thread List of substrings

I was about to post a similar solution, but you beat me to it ;-P

The only comment I would make is use foreach instead of map. In void context map will build a list to return, which just gets thrown away.

Replies are listed 'Best First'.
Re: Re: Re: List of substrings
by kvale (Monsignor) on Jun 24, 2002 at 18:49 UTC
    That's a good point. I was going to use the map to build a substring array, but changed my strategy halfway through and didn't clean up. Here is a corrected version:
    use strict; my $string = shift; my %seen; foreach (0..(length $string) - 1) { my $temp = $string; substr $temp, $_, 1, ""; print "$temp\n" unless $seen{$temp}++; }
    Thanks!

    -Mark