Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^4: Perl Parsing Based on Supplied Precedence

by protist (Monk)
on Nov 07, 2012 at 11:49 UTC ( #1002661=note: print w/replies, xml ) Need Help??

in reply to Re^3: Perl Parsing Based on Supplied Precedence
in thread Perl Parsing Based on Supplied Precedence

"&&" and "and" have differing precedences. "and" is lower precedence than "&&". The same goes for "||" and "or"; "or" has lower precedence than "||". "and" actually has lower precedence than "||", as I will demonstrate.

code with "&&":

perl -e 'if(0&& 0||1){print"hello\n"}'



code with "and":

perl -e 'if(0and 0||1){print"hello\n"}'

(outputs nothing)

Replies are listed 'Best First'.
Re^5: Perl Parsing Based on Supplied Precedence
by wirito (Acolyte) on Nov 07, 2012 at 12:01 UTC
    Yes, you are right. I meant to say:
    '&&' and 'and' operator has higher precedence than '||' and 'or' respectively
    English is not my first language as you can notice :)

      Ah. After I saw your precedences in your example below, I was confused because you seemed to understand haha. I will note here that I was not attempting to mirror Perl precedences in my example precedence, only create a precedence for testing purposes. Your precedence list is more Perl-like.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002661]
usemodperl enters an empty gate

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2018-06-23 19:02 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.