use File::Basename; my $dirname = dirname ("lib/this/that/other.txt");