my $path = "/path/ending/with/a/filename"; my $file = (split(/\//,$path))[-1]; print "$file\n";