use File::Spec; $path = "\path1\path2\path3\file.ext"; ($volume,$directories,$file) = File::Spec->splitpath($path); print "$file";