Daniel Wilson wrote:
> Hello Perl World!
>
> I need a little help..
>
> I currently have the followings (hard coded) definition in one of my
> perl program that I am currently upgrading.
>
> # A five by five Hash Array
> my @GlobalArrayRef;
> $GlobalArrayRef[0] = [ [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0],
> [0,0,0,0,0], [0,0,0,0,0] ];
>
> I need to change this to where I can set the hash array size dynamically
> (during runtime) and not hard coded to a specific size. Any Ideas?
Just do a double foreach loop to create dynamically all the default
elements of the arrays.
my @GlobalArray;
foreach my $outer (0 .. 5) {
foreach my $inner (0 .. 5) {
$GlobalArray[$outer][$inner] = 0;
}
}
Adjust to suit - I used a straight doubly indexed array.
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs