in reply to Trimming Paths with regexes

my $path='/foo/bar'; my @dirs=split(/\//,$path); $"='/'; $\="\n"; while (@dirs) { my $str="@dirs" || "/"; print $str; pop @dirs; }
outputs
/foo/bar /foo /
Yves