while ($get_gal =~ m#(http://{...}.jpg)#g) { my $image = get($1); my ($height, $width) = imgsize(\$image); next if $height > $max_height or $width > $max_width; push @found_images, $1; }