Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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 surveying the Monastery: (8)
As of 2015-07-02 01:46 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 (25 votes), past polls