in reply to Inputing info into Nested Arrays
You can access elements with 2 array subscripts - $array[0][0] is "foo", $array[0][1] is "bar", $array[1][0] is "abc", etc.@array = ( [ "foo", "bar"], [ "abc", "def"] );
Supposing that your file of projects had each project on 1 line, you could do this:
while ( <FILE> ) { push @array, [ split ]; }
Then to print it back out,
for $i (0..$#array) { for $j (0..$#{$array[$i]}) { print "Element $j of project $i is $array[$i][$j]\n"; } }
See The Perl Data Structures Cookbook for more info.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Inputing info into Nested Arrays
by She-wolf (Sexton) on Aug 21, 2000 at 20:45 UTC | |
by Cirollo (Friar) on Aug 21, 2000 at 20:52 UTC | |
by She-wolf (Sexton) on Aug 21, 2000 at 20:56 UTC | |
by merlyn (Sage) on Aug 21, 2000 at 20:58 UTC | |
by She-wolf (Sexton) on Aug 21, 2000 at 21:06 UTC | |
|