This question may look like repetitive but I am confused with the concept. I searched this but couldn't get the answer. So finally I am posting this on forum
I am having a text file with data as
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
I want to create array of array. Code i am writing for this is
#! /usr/bin/perl
#use strict;
#use warnings;
open (FH, "8.txt");
$i = 0;
while (<FH>) {
@temp = split;
push @AoA, [ @temp ];
foreach (@temp) {
push @{$AoA[$i]}, $_;
}
$i++;
}
print $$AoA[0][0];
I am not getting output. I know the shortest answer that is
push @$AoA, [ split ]
But I need the answer as above mentioned to understand the concept
push @$AoA, [ split ];.use strict; use warnings;. It's going to catch 6 or 7 errors in your code.print $$AoA[0][0]does not refer to the@AoAarray. If you had not commented out strict and warnings, you would not have made this mistake.strictandwarningsback on. Fix the problems they tell you about, and you will probably have correct code, or at least something closer thereto. People will be more willing to help you if you make some effort to conform to generally accepted standards of good code, and that includes allowing the compiler to help you so we don't have to.