Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Why Perl boolean expression sometimes treated as lvalue?

by Anonymous Monk
on Feb 08, 2013 at 13:22 UTC ( #1017815=note: print w/replies, xml ) Need Help??


in reply to Re: Why Perl boolean expression sometimes treated as lvalue?
in thread Why Perl boolean expression sometimes treated as lvalue?

Interesting ... note the parens, perl parses it correctly

$ perl -MO=Deparse,-p -le " $a= 1 && 2; print $a; " BEGIN { $/ = "\n"; $\ = "\n"; } ($a = 2); print($a); -e syntax OK $ perl -MO=Deparse,-p -e " $a && $b = 3; " Can't modify logical and (&&) in scalar assignment at -e line 1, near +"3;" -e had compilation errors. (($a && $b) = 3);

But there is no code to execute this :) its default Can't modify %s http://perl5.git.perl.org/perl.git/blob?f=op.c#l2020

2012 /* FALL THROUGH */ 2013 default: 2014 nomod: 2015 if (flags & OP_LVALUE_NO_CROAK) return NULL; 2016 /* grep, foreach, subcalls, refgen */ 2017 if (type == OP_GREPSTART || type == OP_ENTERSUB 2018 || type == OP_REFGEN || type == OP_LEAVESUBLV) 2019 break; 2020 yyerror(Perl_form(aTHX_ "Can't modify %s in %s", 2021 (o->op_type == OP_NULL && (o->op_flags & OPf +_SPECIAL) 2022 ? "do block" 2023 : (o->op_type == OP_ENTERSUB 2024 ? "non-lvalue subroutine call" 2025 : OP_DESC(o))), 2026 type ? PL_op_desc[type] : "local"));

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017815]
help
Chatterbox?
[ww]: (but pls don't s/senior/senile/ ... not yet
[karlgoethebier]: A bit more audience now: The Impact of Information Sources on Code Security Very interesting IMHO...
[karlgoethebier]: ..it's about copy & paste ;-)
[ww]: Wonder what IEEE would have thought w/survey based on PM/perl
[ww]: s/thought/found/
[erix]: that title is a broken* sentence, no? But maybe that's deliberate
[karlgoethebier]: ww:My first thought, to be honest...
[erix]: and those authors' names don't look like native english speakers. Then again, neither am I :)
[karlgoethebier]: but the set of test persons is very small, like in medical studies: "We analyzed 50..."

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-09-25 14:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (280 votes). Check out past polls.

    Notices?