Hi all, Before chasing down and fixing an undef var earlier on in a trace path, I had the following code. I've finally gathered that fixing bugs and validating data upstream is far better than writing code to fix it later (of course, I had to write code to find out what was happening).
The last two lines do not do what I originally was hoping they would.
The code has been fixed.
I _thought_ that if I use the 'or assign' op, it would either append the
$payment amount to the existing hash element, or if it didn't exist, it
would create one from the current $payment.
I recalled that a hash element will be created dynamically, which
rendered my code useless, and is what lead me to perform further
diagnostics and trace upstream.
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:
while ( my $ledger_ref = $sth->fetchrow_hashref ) {
# print Dumper $ledger_ref;
# next();
my $amount = $ledger_ref->{amount};
my $payment = $ledger_ref->{payment};
my $username = $ledger_ref->{username};
# print "$amount :: $payment :: $username\n";
$user_ref->{$username}{payment} += $payment ||= $payment;
$user_ref->{$username}{amount} += $amount ||= $amount;
Steve
smime.p7s
Description: S/MIME Cryptographic Signature
