Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

Disappointments:

# 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.


Comment on Re: @_ still mystifies me
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://171080]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2015-07-03 16:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (54 votes), past polls