in reply to Code review
So, this single statement is possible: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}++ } }
1. The comma operator serves no purpose in the above code. Prefer ; instead.scalar @ARGV ? $Y{$y} += @ARGV : $Y{$y}++;
Or, this is a possibly of what was meant:foreach (@ARGV) { next if $y eq $_; # don't count any occurrences of # $y $Y{$y}++, }
scalar @ARGV ? $Y{$y} += (grep $y ne $_, @ARGV) : $Y{$y}++; Without some more English language explanation, I have no idea what the code is supposed to do.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Code review
by hv (Prior) on Mar 07, 2024 at 12:14 UTC |