in reply to Regular Expression Help

This strips off the last directory if more than one directory in path:
foreach my $path (<DATA>) { chomp($path); $path =~ s{(?<=[^/])/[^/]+/?$}{}xms; print $path . "\n"; } __DATA__ /rootdir/sub funky ---doodash/la la la/Proposal for Buttering My Feet /rootdir/sub1/sub2/sub3/sub4/ /rootdir/sub1/sub2/sub3/sub4/file/ /rootdir/ /
Hope this helps