
Laurent_R
Enthusiast
Sep 17, 2012, 8:16 PM
Post #3 of 5
(1413 views)
|
|
Re: [Lynn] 2D Array with random numbers
[In reply to]
|
Can't Post
|
|
Try something like this to populate a 2D array:
my @two_D_array; foreach my $i (0..4) { foreach my $j (0..4) { $two_D_array[$i][$j] = 1; } } There could be a number of shortcuts which could reduce the nember of lines in the code, but I wanted to make it as simple as possible for you to understand the principle. Of course, here I have just put ones in each element of the 2D_array. You would have to put instead your random numbers in the appropriate range required by what you want to do.
|