I am very confused as to what this thing is supposed to do!
I ran just the first part of the code and this is what I get.
The n array is not multi-dimensional. There is not data in that array anyway in this first loop.
$x[$n[$j]][$j] doesn't make sense to me.
Update: I guess
$x[$n[$j]//=0][$j] = $column[$j]; "works", but I still don't quite get it.
#! /usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
my @n=0;
my @x;
my $j;
my $i;
my $dg;
my @x_jack;
my @x_tot=0;
my $cols;
my $col_start=0;
# read in the data
while(<DATA>)
{
my @column = split();
$cols=@column;
foreach my $j ($col_start .. $#column) {
$x[$n[$j]][$j] = $column[$j];
$x_tot[$j] += $x[$n[$j]][$j];
$n[$j]++;
}
}
print "\n";
print "THE X ARRAY IS\n";
foreach my $rowref (@x)
{
print "@$rowref\n";
}
print "\n";
print "THE N ARRAY IS:\n";
print "@n";
=PRINTS:
Use of uninitialized value within @n in array element at line 22, <DAT
+A> line 1.
Use of uninitialized value within @n in array element at line 23, <DAT
+A> line 1.
Use of uninitialized value within @n in array element at line 22, <DAT
+A> line 1.
Use of uninitialized value within @n in array element at line 23, <DAT
+A> line 1.
Use of uninitialized value within @n in array element at line 22, <DAT
+A> line 1.
Use of uninitialized value within @n in array element at line 23, <DAT
+A> line 1.
THE X ARRAY IS
1.1 2.1 3.1 4.1
1.2 2.2 3.2 4.2
1.3 2.3 3.3 4.3
1.4 2.4 3.4 4.4
THE N ARRAY IS:
4 4 4 4
=cut
__DATA__
1.1 2.1 3.1 4.1
1.2 2.2 3.2 4.2
1.3 2.3 3.3 4.3
1.4 2.4 3.4 4.4