use strict; use warnings; use File::Spec::Functions qw(splitdir catdir splitpath); my $path = "/a/b/c/d/e/f"; my @foo = splitdir ($path); my $subpath = catdir (@foo[1..3]); # Note that the "volume" is blank so skip that print "Sub path = $subpath\n"; #### Sub path = a\b\c