Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Surprising Precedence/Context

by Paladin (Vicar)
on Jun 02, 2017 at 18:03 UTC ( #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
Node Status?
node history
Node Type: note [id://1191995]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2019-10-15 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?