Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: @_ still mystifies me

by cLive ;-) (Parson)
on Jun 01, 2002 at 15:33 UTC ( #170920=note: print w/ replies, xml ) Need Help??


in reply to @_ still mystifies me

Presedence. "@_ is always evaluated to a true" - No, "@lexlist = @_" is.

I think these braces are in the right place:

my @lexlist = @_ or sort keys %lexicon; # read as (my @lexlist = @_) or (sort keys %lexicon);
What you want is:
my @lexlist = @_ || sort keys %lexicon; # read as my @lexlist = (@_ || sort keys %lexicon);
Or use braces:
my @lexlist = (@_ or sort keys %lexicon);
Hopefully the braces make it a little more readable :) or, and & not have much lower presedence than || && and !

In my experience, to avoid such confusion, I avoid the English versions...

cLive ;-)

Update: see below :) /me eats humble pie and revisits old scripts to see why this has never caused me a problem b4...


Comment on Re: @_ still mystifies me
Select or Download Code
Re: Re: @_ still mystifies me
by Anonymous Monk on Jun 01, 2002 at 17:32 UTC
    You didn't test your code, and your answer doesn't work.
Re^2: @_ still mystifies me
by Aristotle (Chancellor) on Jun 01, 2002 at 18:36 UTC
    This won't work because or forces scalar context on its operands.
    Update: Thanks, merlyn.
    ____________
    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2014-12-29 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (191 votes), past polls