in reply to How do I get the directory containing a given file?
use Cwd qw(abs_path); use File::Basename; my $dir = dirname(abs_path($file));
Turning this into a complete perl program is left as an exercise to the reader.
In Section
Seekers of Perl Wisdom