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; } [download]
/foo/bar /foo / [download]