John W. Krahn wrote: > Steve Bertrand wrote: >> What I want to know, is if someone could place parens to help me better >> understand the precedence order in the last two lines. I know they are >> legal as they do work, but I don't know how the interpreter is >> interpreting them:
>> $user_ref->{$username}{payment} += $payment ||= $payment; >> $user_ref->{$username}{amount} += $amount ||= $amount; > Assignments happen right-to-left so, for instance, this will work: > > my $x = my $y = my $z = some_value(); > > where $z will be assigned to first and then $y will be assigned the > result of the first assigment and $x will be assigned the result of the > second assignment. > > $ perl -MO=Deparse,-p -e'my $x = my $y = my $z = some_value();' > (my $x = (my $y = (my $z = some_value()))); > -e syntax OK Ahh. Not only did you make it understandable verbally, but also rendered it in a way that I (and others) could yank/put it in order to find out the parenthesis of my own code for myself!: % perl -MO=Deparse,-p -e \ 'my $user_ref->{$username}{amount} += $amount ||= $amount;' ($my $user_ref{$username}{'amount'} += ($amount ||= $amount)); -e syntax OK Nice! Perl just tells me... after I've been informed :) Thanks John! Steve
smime.p7s
Description: S/MIME Cryptographic Signature