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

Re: Surprising Precedence/Context

by Paladin (Vicar)
on Jun 02, 2017 at 18:03 UTC ( [id://1191995]=note: print w/replies, xml ) Need Help??


in reply to Surprising Precedence/Context

As you can see below, the = binds tighter than the and, so your second example is parsing as:
(my($yes2)=defined $bad) and -f $bad;
Deparse:
[~]$ perl -MO=Deparse -e 'my($yes2) = defined $bad and -f $bad;' -f $bad if my($yes2) = defined $bad; -e syntax OK

Replies are listed 'Best First'.
Re^2: Surprising Precedence/Context
by Anonymous Monk on Jun 02, 2017 at 18:46 UTC
    When looking at precedence issues, the -p (full parens) Deparse option is helpful.
    > perl -MO=Deparse,-p -e 'my($yes2) = defined $bad and -f $bad;' ((my($yes2) = defined($bad)) and (-f $bad));
Re^2: Surprising Precedence/Context
by williams (Beadle) on Jun 02, 2017 at 19:04 UTC

    Ouch. Thanks.

    Jim

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-28 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found