use File::Finder; use Image::Size; my @starting_points = qw(.); my %images = File::Finder ->type('f') ->gather(sub { my($x, $y, $type) = imgsize($_); $type ? ($File::Find::name, $type) : (); }, @starting_points);