Hi

The following code produces the correct array output but the second print occurs after the first print! I don't see why....

#!/usr/bin/perl -w use strict; sub sub_myarray_test; sub sub_myarray_test { my @my_array = ("one", "two", "three"); my @my_array2 = ("four", "five", "six"); print "\n\tIn subroutine \@my_array = @my_array\n"; print "\tIn subroutine \@my_array2 = @my_array2\n\n"; return \(@my_array, @my_array2); } my ($test_array, $test_array2) = sub_myarray_test; print "test_array: @$test_array " . #{${@{$test_array}}} . "\n"; print "test_array2: @$test_array2\n"; exit;
bash-2.05b# test_array

In subroutine @my_array = one two three
In subroutine @my_array2 = four five six

test_array2: four five six

test_array: one two three 1bash-2.05b#

VERSION: Perl 5.8.0 r12 on Gentoo Linux 1.4 (custom)

Any clues?

Thanks

jason

THANKS! That was pretty dumb... and simple... grrr ;-)


In reply to printing referenced arrays weirdness by jfroebe

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.