in reply to pre-size a two-dimensional array
Perl doesn't have two-dimensional arrays. What you are actually using is an array where each element happens to be a reference to another array.
When dealing with a single array, Perl will expand it as needed, so there's rarely any need to pre-define its size. Because of autovivification, the same applies to "2d arrays".
If you really did want to pre-allocate your "2d array", you could do it as follows:
my @summary; $#summary = $numWks - 1; foreach (@summary) { my @days; $#days = 7 - 1; $_ = \@days; }
However, I think a simple my @summary; will suffice for you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pre-size a two-dimensional array
by rightfield (Sexton) on Jul 12, 2007 at 03:44 UTC | |
by GrandFather (Saint) on Jul 12, 2007 at 04:23 UTC | |
by chrism01 (Friar) on Jul 12, 2007 at 04:16 UTC | |
|
Re^2: pre-size a two-dimensional array
by Anonymous Monk on Jul 16, 2007 at 06:07 UTC |