$ perl -MFile::Spec -wle 'my $path = shift; my $last = (File::Spec->splitpath($path))[-1]; print $last' /etc/httpd/conf conf $ perl -MFile::Spec -wle 'my $path = shift; my $last = (File::Spec->splitpath($path))[-1]; print $last' /etc/httpd/conf/httpd.conf httpd.conf #### $ perl -MPath::Class -wle 'my $path = shift; my $obj = file($path); print +(File::Spec->splitpath($obj))[-1]' /etc/httpd/conf/httpd.conf httpd.conf $ perl -MPath::Class -wle 'my $path = shift; my $obj = dir($path); print +(File::Spec->splitpath($obj))[-1]' /etc/httpd/conf conf