my %Y; while (<>) { ... my ($y) = ... ; next unless $y; # Add the scalar number of elements in @ARGV to the hash # Always add at least 1 to the hash even if @ARGV contains # no elements # the value $y is meaningless and plays no role if(@ARGV) { # next is always executed regardless of $y eq $_ foreach (@ARGV) { $Y{$y}++,next if $y eq $_; } } else { $Y{$y}++ } } #### scalar @ARGV ? $Y{$y} += @ARGV : $Y{$y}++; #### foreach (@ARGV) { next if $y eq $_; # don't count any occurrences of # $y $Y{$y}++, }