in reply to Re: Re: Messing with a substring
in thread Messing with a substring
I'm pretty damn sure I don't understand the problem at all... But maybe, just maybe... Anyway, I'll give it a shot. How about:
my $str = "/One/Two/Three"; my @paths = ($str); push @paths, $str while($str =~ s{^(/.+)/[^/]*$}{$1}); print "$_\n" for @paths;
That prints:
/One/Two/Three /One/Two /One
Is that at all what you're looking for?
Update: Of course, that's destructive to $str so be sure it's a copy.
bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (bbfu) Re: Messing with (my head) a substring
by psypete (Initiate) on Apr 01, 2001 at 09:28 UTC | |
by bbfu (Curate) on Apr 01, 2001 at 09:42 UTC | |
by repson (Chaplain) on Apr 01, 2001 at 15:01 UTC | |
by bbfu (Curate) on Apr 02, 2001 at 03:39 UTC |