Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: ?: (conditional operator)

by Masem (Monsignor)
on Aug 23, 2001 at 17:46 UTC ( #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");
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 - || "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.

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2022-06-26 04:56 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (83 votes). Check out past polls.