use strict; use warnings; use File::Spec; my $dir = (File::Spec->splitdir('/path/to/dir_i_want'))[-1]; print "$dir\n"; __END__ dir_i_want