$ 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