use Cwd qw(abs_path); use File::Basename; my $dir = abs_path(dirname($file));