the_dark_lord has asked for the wisdom of the Perl Monks concerning the following question:
Hi I was writing a program and instead of adding values in 2 different hashes, I summed 2 hashes themselves.
I caught my mistake but the value printed by the incorrect code made me curious.
Basically, if I add 2 hashrefs, I get some value which depends only on the first hashref added.
Example: If I try to run the code
my $a = { # 'key1' => 'valdsgdjgf`', # 'key2' => 'val2', }; my $b = { # 'key3' => 'val3', # 'key4' => 'val4', }; my $sum = $a + $b; print "$sum\n";
I get some random value: 15401280
If I make a change to hashref $a, then this value changes. But if I make a change to hashref $b, then this value does not change.
Does anybody know what this value is?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Addition of hashes
by NetWallah (Canon) on Feb 03, 2017 at 07:25 UTC | |
|
Re: Addition of hashes
by vinoth.ree (Monsignor) on Feb 03, 2017 at 07:19 UTC | |
by morgon (Priest) on Feb 03, 2017 at 15:30 UTC | |
|
Re: Addition of hashes
by BillKSmith (Monsignor) on Feb 03, 2017 at 14:14 UTC |