my %Y; while (<>) { ... my ($y) = ...; next unless $y; if (@ARGV) { for (@ARGV) { $Y{$y}++; next if $y eq $_; } } else { $Y{$y}++; } }