use File::Spec::Functions qw(canonpath splitdir); my (@path) = splitdir canonpath $path; # @path now contains ('', 'home', 'a', 'ff.pl') print $path[2], "\n";