use File::Basename; my ($filename, $dir, $suffix) = fileparse($path); print "The directory is: $dir\n";