use File::Basename; my $path = '/home/username/public_html/somepath/2004-04-14-0002136'; my $filename = basename($path); print $filename, "\n";