my $found; foreach (@file) { if (/^\Q$storeline|\E/ && $found++) # First hit skipped { duped_ids($storeline); return; } } unless ($found) { no_match($storeline); return; }