in reply to Re^2: hashes with multiple values per key
in thread hashes with multiple values per key

Yes, "$yahoo{$key} += $value;" is the same as "$yahoo{$key} = $yahoo{$key} + $value;". Look under "Assignment operators" in perlop.

Replies are listed 'Best First'.
Re^4: hashes with multiple values per key
by GrandFather (Saint) on Aug 07, 2007 at 01:10 UTC

    not quite. Consider:

    use strict; use warnings; my $foo = undef; my $bar = undef; $foo += 1; $bar = $bar + 1;

    Generates the warning:

    Use of uninitialized value in addition (+) at noname1.pl line 8.

    Note that it is the $bar line only that generates the warning. The update assignment operators do not generate an uninitialized value warning when the left hand side is undefined, but the other non-boolean binary operators do. See perlsyn Declarations.


    DWIM is Perl's answer to Gödel