in reply to Re: Code review
in thread Code review

The first version does not allow for empty @ARGV; both versions do not allow for the possibility that @ARGV may have repeated elements.

I think a short form that preserves all the current behaviour could look like this:

... next unless $y; $Y{$y} += @ARGV ? (grep $y eq $_, @ARGV) : 1;

It would, though, be preferable to have some clue about what the code is intended to achieve: it is always possible that the behaviour on repeated elements is unintentional or irrelevant.

Replies are listed 'Best First'.
Re^3: Code review
by ikegami (Patriarch) on Mar 07, 2024 at 05:27 UTC

    The first version does not allow for empty @ARGV

    That's not true. If you remove the if, sure, but noone said to do that.

      You're quite right, my apologies for the error.