[oak perl] stay away from nested array(s)?
Kester Allen
kester at gmail.com
Sat Jan 15 17:38:18 PST 2005
Hi Sandy--
I'd say the book is trying to discourage this type of thing:
my @array = ( '00', '01', '02', '03' );
$array[4] = '04';
in favor of:
my @array = ( '00', '01', '02', '03' );
push @array, '04';
Using push will prevent you from typo-ing "$array[44] = '04';"
which'll result in an array where elements 4 through 43 are undef!
I don't think there's anything wrong with your example:
> @biglist = 1..300000;
> @biggerlist= 1..700000;
> @maybetoobigalist = (@biglist, @biggerlist);
--Kester
On Sat, 15 Jan 2005 14:22:54 +0000, Sandy Santra <santranyc at yahoo.com> wrote:
> The Llama book includes an admonition against adding "new
> items to the end of an array by simply storing them into
> elements with new, larger indices" (3rd ed., page 46).
>
> Is the book trying to dissuade me against:
>
> @biglist = 1..300000;
> @biggerlist= 1..700000;
> @maybetoobigalist = (@biglist, @biggerlist);
>
> I'm asking because I'm not exactlly sure if that's what
> they're talking about. Or/and it's also to encourage a
> newbie like me to learn and use push (instead)...
>
> Am I on the right track here?
>
> --Sandy Santra
>
> _______________________________________________
> Oakland mailing list
> Oakland at pm.org
> http://mail.pm.org/mailman/listinfo/oakland
>
More information about the Oakland
mailing list