in reply to how do I open each line of a text file into seperate arrays?
This will store a reference to each array within one big array, called @majorArray. You can then access each array like this:use strict; open (INPUT, "myFile.txt") || die "Couldn't open file: $!\n"; my @majorArray; while (<INPUT>) { my @minorArray = split('\|', $_); push @majorArray, \@minorArray; }
or you can get at all of the contents of every array like this:my $arrayRef = $majorArray[0]; foreach my $temp (@{$arrayRef}) { print $temp,"\n"; }
If you're having trouble with references, you might want to try checking out How do I loop over a reference to an array? or simply look up references in the documentation. Or, even more simply, push the actual array into the larger array to give yourself a two-dimensional array.foreach my $item (@majorArray) { foreach my $subitem (@{$item}) { print $subitem,"\n"; } }
|
|---|