in reply to Newbies question: initializing data structure
$hash{"COUNTS"} = [ (1) x $length ];
The parentheses around 1 are needed here (they specify a list). Otherwise you'd get one string "1111111111", because in scalar context the x operator multiplies/concatenates a string.
For your second case:
$hash{"LISTS"} = [ map [], 1..$length ];
( () x $length wouldn't work here)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Newbies question: initializing data structure
by roibrodo (Sexton) on Jun 02, 2010 at 11:01 UTC | |
by almut (Canon) on Jun 02, 2010 at 11:09 UTC | |
|
Re^2: Newbies question: initializing data structure
by roibrodo (Sexton) on Jun 02, 2010 at 11:01 UTC | |
by roibrodo (Sexton) on Jun 02, 2010 at 11:10 UTC | |
by almut (Canon) on Jun 02, 2010 at 11:18 UTC |