Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Hash of arrays generation

by SuicideJunkie (Vicar)
on Sep 04, 2012 at 18:17 UTC ( #991673=note: print w/replies, xml ) Need Help??

in reply to Hash of arrays generation

The former will make $HoA{$key} an array ref regardless of what it was before.

The latter will cause problems if $HoA{$key} was something other than an arrayref.

use strict; use warnings; my %HoA; $HoA{'bar'} = 'baz'; @{$HoA{'foo'}} = (1,2,3); @{$HoA{'bar'}} = (1,2,3);
Gives: Can't use string ("baz") as an ARRAY ref while "strict refs" in use at line 6.

Replies are listed 'Best First'.
Re^2: Hash of arrays generation
by nemesisgus (Acolyte) on Sep 05, 2012 at 00:31 UTC

    Thank you both for answering.

    I didn't consider the case of an already defined key element. Thanks for pointing it out!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991673]
[choroba]: erix Seems too complex
[erix]: do you mean: 'it can be done simpler', or 'it won't work' ?
[choroba]: I wouldn't want to maintain it in the current form
[erix]: ok, but mainainability comes after it has been made to work :)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2018-01-19 08:33 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (216 votes). Check out past polls.