Help for this page
use strict; use warnings; ... my $str = "/rootdir/sub1/sub2/sub3/sub4"; print substr($str, 0, rindex($str, "/", length($str) - 2)); }
/rootdir/sub1/sub2/sub3 /rootdir/sub1/sub2/sub3