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.

In reply to Re: Pushing rows of data into array by Marshall
in thread Pushing rows of data into array by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.