... while () { next if /^\s*$/; if (/^.+?\s(.+?)\s/) { print $_ if not exists $hash{$1}; # note HERE } } ..