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 reply to Re: @_ still mystifies me
by tadman
in thread @_ still mystifies me
by PetaMem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |