chomp($str = `dirname $str`); #### use File::Basename; my $dir = dirname($filename);