in reply to Pushing rows of data into array

I got a little lost in what you are trying to do. But looks like you are going to get a reference to an Array of Array. You don't want to "flatten" this out. It will be easier to process each row if you maintain this structure. See: http://perldoc.perl.org/5.8.8/perldsc.html#ARRAYS-OF-ARRAYS.

Here is some example code:

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @data = ([qw/one two three four five/], #array of array [qw/ a b c d e/],); my $dataref = \@data; my @all; push @all,@$dataref; #not sure of need for this? but works. print Dumper \@all; print scalar @{$dataref->[0]},"\n"; #number of elements in row[0] # i.e. "5" print $dataref->[0][1],"\n"; #prints "two", 2nd element of row +0 foreach my $element (@{$dataref->[0]}) #each element of row [0] { print "$element "; } print "\n\n"; foreach my $row_ref (@all) #deal with references to rows { print "number of elements = ".scalar @$row_ref," @$row_ref\n"; # of course number of elements will be the same in each row, #so only need to check for row[0] as above } __END__ $VAR1 = [ [ 'one', 'two', 'three', 'four', 'five' ], [ 'a', 'b', 'c', 'd', 'e' ] ]; 5 two one two three four five number of elements = 5 one two three four five number of elements = 5 a b c d e
To find "how many columns", check the number of elements that are in the row 0 of the data array.