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

Re: ?: (conditional operator)

by Masem (Monsignor)
on Aug 23, 2001 at 17:46 UTC ( [id://107321]=note: print w/replies, xml ) Need Help??


in reply to ?: (conditional operator)

Based on perlop , the terany operator (?:) is just one precidence level above the "operate and set" operators .=, +=, etc.

Thus, perl is seeing:

print ($x ? $x.="hello" : $x.="Bye");
as
print ( ( $x ? $x.="hello" : $x ) .="Bye");
and not as
print ( $x ? $x.="hello" : ( $x.="Bye" ) );
The solution is, therefore, to use the last form to get it the way you want.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: Re: ?: (conditional operator)
by pmas (Hermit) on Aug 23, 2001 at 18:56 UTC
    Ovid just asked similar Weird syntax question and htoug has elegant solution using wonderfull B::Deparse module.

    pmas
    To make errors is human. But to make million errors per second, you need a computer.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-26 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found