in reply to Extending Array
$thing is a hash reference, not an array. See perldata and perlreftut for some more information.
Two ways to extend it:
$thing = { %$thing, 'C' => 'cutie', 'D' => 'pie' }; # OR $thing->{C} = 'cutie'; $thing->{D} = 'pie';
The first one generates a new hash and a new reference to it, the second adds items to the existing hash. Which one you should use depends on your use case (and is only relevant if there are other references to the same hash somewhere).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extending Array
by sriharsha.sm (Initiate) on Mar 21, 2012 at 18:53 UTC | |
by moritz (Cardinal) on Mar 21, 2012 at 19:07 UTC |