sub is_image_size_ok { local $_ = @_ ? $_[0] : $_; my $image = get($_); my ($height, $width) = imgsize(\$image); return $height <= $max_height and $width <= $max_width; } my @found_images = grep is_image_size_ok, map m#(http://{...}.jpg)#g, $get_gal;