in reply to Procesing directories
But, really, why aren't you using File::Find?
if ($tmp =~ /\.\.?/) { next; } [download]
$tmp = "$dir/$tmp"; if ($tmp =~ /^(\w*)\.(jpg|jpeg)$/) [download]