use Image::Size; for(@files) { next unless /.{2,}\.jpg$/; # could also be just /..\.jpg$/ my ($x, $y) = imgsize($_); print "$_: x=$x, y=$y
\n"; }