$ perl -MData::Dumper -e '$p="foo/bar/rab/oof";@p=split"/",$p;@p=reverse map{"/".join"/",@p[0..$_]}reverse(0..$#p);print Dumper @p'