use File::Spec::Functions qw(splitpath); my (undef,undef,$file)=splitpath($path);