while(<>) { if(/^PORNUM:\s*(\S+)/m) { if(exists $skip{$1}) { # It matches, and ought to be skipped next; } } print; }