This is not my exact script, but I wrote it in a similar format. Trying to create an array of arrays in one subroutine, and then returning it as a variable, to be used later in a second subroutine. When I test by printing indices from the arrays in the array of arrays, however, it does not seem to work (it says, for instance, "Use of uninitialized value $array1[0] in concatenation (.) or string"].

my @array1; my @array2; my @array3; my @array_array; @array_array = @{ &firstRoutine() }; &secondRoutine(\@array_array ); sub firstRoutine{ my $count = 0; while (<INPUT>){ my @line = split( /\s+/, $_ ); $array1[$count] = $line[0]; $array2[$count] = $line[1]; $array3[$count] = $line[2]; $count = $count + 1; } my @array_array; push( @array_array, @array1, @array2, @array3); return \@array_array; } sub secondRoutine { my (@array1, @array2, @array3) = { shift @_ }; print ("Test first value in array1: $array1[0]"); print ("Test third value in array2: $array2[2]"); print ("Test fifth value in array3: $array3[4]"); }

In reply to Array of arrays by SuzuBell

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.