use File::Basename; my $dir = dirname($filename);