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

Re: Conditional Operator Confusion

by GrandFather (Sage)
on Nov 29, 2006 at 12:47 UTC ( #586677=note: print w/ replies, xml ) Need Help??


in reply to Conditional Operator Confusion

You may like:

for(1..10){ $x= $_ > 5 && 'foo' || 'bar'; print "$_:$x\n"; }

instead. Update: You may like:

print"$_:${[$_>5&&'foo'||'bar']}[0]\n"for 1..10;

even better.


DWIM is Perl's answer to Gödel


Comment on Re: Conditional Operator Confusion
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2015-07-03 00:14 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 (47 votes), past polls