in reply to Auto-filling an array
And then there's
my @list; push(@list, 'N/A') for (1..14);
Perl's push, pop, shift and unshift are extremely efficient. They don't copy the entire array, unlike @list=('N/A')x14. In addition, for (a..b) is also very efficient. It is optimised to not create a list, unlike ('N/A')x14.
That said, I like the idea of leaving the array undefined, and replacing each undef with "N/A" when printing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Auto-filling an array
by tlm (Prior) on Mar 28, 2005 at 23:39 UTC | |
|
Re^2: Auto-filling an array
by nimdokk (Vicar) on Mar 28, 2005 at 19:13 UTC |