roibrodo has asked for the wisdom of the Perl Monks concerning the following question:
I would like to initialize %hash with two keys: $hash{"COUNTS"} will point to an array of size $length all initialized with 0's. $hash{"LISTS"} will point to an array of size $length, where each element is an empty list (so I can push into it).
I know how to achieve that using lopping, creating temporary structures and referencing to them, but I'm quite sure there's a more elegant solution. for example, I think that $hash{"COUNTS"} can be initialized using:
$hash{"COUNTS"}=[(0) x $length] OR $hash{"COUNTS"}=[0 x $length]I'm not sure if the braces around the zero have any effect. Do they mean a singleton with zero in it? If I want a simple scalar, should I omit them? And how should i initialize $hash{"LISTS"}? Maybe something like
$hash{"LISTS"}=[() x $length]thanks!
|
|---|