if ($filename =~ m/\.jpe?g$/i) { print ("yep, it is a jpg!\n"); }