in reply to @_ still mystifies me
Disappointments:
Although there are many good solutions posted here, how about a bad one?# Unfortunate scalar conversion my @foo = @_ || @bar; # Unfortunate error, not DWIM-compatible my @foo = @_; @foo ||= @bar;
Hey, it works, but it's quite brittle. If you even think about changing the order of the parameters, you're into SCALAR land.my @bar = qw[ dog cat frog ]; sub foo { my @foo = grep{length}(@_, (!@_ && @bar)); print join(',', @foo),"\n"; }
|
---|
In Section
Seekers of Perl Wisdom