Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
So, I was curious about this and looked all over Super Search and google but I am probably forming my search query poorly.

My question is one that I have wondered about for sometime but never pursued out of lack of time. However, I am very curious now to learn how I could do this if at all.

The following code attempt fails:

perl -e ' $a = 5; $b = 5; $c = 5; if ( ($a == $b) == $c ) { print "They are the same\n"; } else { print "They are not the same\n"; } '
Obviously, I had to declare precedence so that the intperpretter wouldn't get confused as to what to compare first then next , but, this still doesn't work. I've tried various other syntactical tweaks in the condition as well but haven't been able to find one that works. I know that you could and or && this but I would like to avoid that if possible.

if ( $a == $b and $a == $c ) { print "true\n"; } else { print "not true"; }
I am thinking that this kind of operation would make it very easy to see if a number of variables all equal the same value which could be done in one condition without extra operators or repeating the lvalue more than once.

_ _ _ _ _ _ _ _ _ _
- Jim
Insert clever comment here...


In reply to Can If-then conditions do ($a = $b = $c) type expressions? by snafu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-20 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found