Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: @_ still mystifies me

by tadman (Prior)
on Jun 02, 2002 at 22:49 UTC ( #171080=note: print w/replies, xml ) Need Help??

in reply to @_ still mystifies me

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://171080]
[LanX]: use module :all ?
[Lady_Aleena]: Lax, that would take it down to a little less than 100 characters. The module name is nearly 80 characters long.
Lady_Aleena has fumble fingers today.
[Lady_Aleena]: Sorry for the name typo LanX.
[LanX]: never lad_ena!
[LanX]: ;)
[Lady_Aleena]: IMO, Fancy::Join:: Grammatical isn't bad, but RolePlaying:: WorldBuilding:: WorldBuildersGuide book::ClimateTerra inSubsistance is on the long side.

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2017-05-24 21:57 GMT
Find Nodes?
    Voting Booth?