use File::Basename; my $dir = dirname $path; print "The directory is: $dir\n";