Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: @_ still mystifies me

by cLive ;-) (Prior)
on Jun 01, 2002 at 15:33 UTC ( [id://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...

Replies are listed 'Best First'.
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.
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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-23 07:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found