use File::Spec; my $fullpath = "/path/ending/with/a/filename"; my ($volume, $path, $file) = File::Spec->splitpath($fullpath); print "$file\n";