V
vorticitywolfe
Hello, a newbie question...
I have a file that looks like this:
########test.txt#########
28 0742 1715 0656 1800 0602 1839 0506 1920 0430 1956 0427 2011
29 0741 1716 0600 1840 0505 1922 0429 1957 0427 2011
0454
30 0740 1718 0558 1842 0503 1923 0429 1958 0428 2011
0455
31 0739 1719 0556 1843 0428
1959 0457
#######################
and I read it with this code:
###########test.pl###########
while(my $line = <INPUT>){
push @AoA, [ split ];
}
###########################
I am trying to read it into a multi dimensional array, much like the
perldoc perllol; however, I'm running into a couple of problems.
1.) What does this mean in the documentation, i.e. I don't get what
function the line should be calling , and it is not explained? I see
that it is trying to index $AoA with row $x and column $y, but the
function is throwing me off.
for $x (1 .. 10) {
for $y (1 .. 10) {
$AoA[$x][$y] = func($x, $y);
}
}
2) the push@AoA, [ split ]; thinks the 3rd column is blank space and
combines the array into 8 elements (for the last line ) as opposed to
13 for the first).
3.) If I print @AoA; I get the: ARRAY(BLAH BLAH) ARRAY(BLAH BLAH). I
know this is because I am not printing a scalar. But the question here
is: Is there a way to print an array without for looping through each
element?
Thanks for all your help in advance!
Jonathan
I have a file that looks like this:
########test.txt#########
28 0742 1715 0656 1800 0602 1839 0506 1920 0430 1956 0427 2011
29 0741 1716 0600 1840 0505 1922 0429 1957 0427 2011
0454
30 0740 1718 0558 1842 0503 1923 0429 1958 0428 2011
0455
31 0739 1719 0556 1843 0428
1959 0457
#######################
and I read it with this code:
###########test.pl###########
while(my $line = <INPUT>){
push @AoA, [ split ];
}
###########################
I am trying to read it into a multi dimensional array, much like the
perldoc perllol; however, I'm running into a couple of problems.
1.) What does this mean in the documentation, i.e. I don't get what
function the line should be calling , and it is not explained? I see
that it is trying to index $AoA with row $x and column $y, but the
function is throwing me off.
for $x (1 .. 10) {
for $y (1 .. 10) {
$AoA[$x][$y] = func($x, $y);
}
}
2) the push@AoA, [ split ]; thinks the 3rd column is blank space and
combines the array into 8 elements (for the last line ) as opposed to
13 for the first).
3.) If I print @AoA; I get the: ARRAY(BLAH BLAH) ARRAY(BLAH BLAH). I
know this is because I am not printing a scalar. But the question here
is: Is there a way to print an array without for looping through each
element?
Thanks for all your help in advance!
Jonathan