use File::Spec; my $file = "../this/is/a/problem/file.pl"; $file = (File::Spec->splitpath($file))[2] if $file; print $file; __END__ file.pl