Hi,

I am trying to do a simple return of a multidimensional array. I hoping to keep it simple, clean, so that I may use channel programming AI like ZPX Engine. $LON is a multidimensional array for this example. Don't care about the array reference at [0]. Want to return $LON and cleanly receive it into a target from the subroutine. [Left Hand] = [Right Hand] programming style. Basically an exact copy without re-processing it again. $a = $b; done.

Super simple example below, did not even put in strict and warnings.

Thank you in advanced.

$ListPeople = (); $ListPeople = &ListOfNames; $counter = 0; while( $ListPeople[$counter][0] ne "" ){ print "$counter. What is my Name: $ListPeople[$counter][0] $ListPe +ople[$counter][1] $ListPeople[$counter][2]\n\n"; $counter++; }; sub ListOfNames{ $LON = (); $LON[0][0] = "Tim"; $LON[0][1] = "O"; $LON[0][2] = "Tay"; $LON[1][0] = "John"; $LON[1][1] = "Fitz"; $LON[1][2] = "Gerald"; $LON[2][0] = "Gerald"; $LON[2][1] = "Fitz"; $LON[2][2] = "John"; return( $LON ); }; exit(0);

Output Should look like

0. What is my Name: Tim O Tay

1. What is my Name: John Fitz Gerald

2. What is my Name: Gerald Fitz John


In reply to Re^3: How to return a two dimensional array from a function in Perl? by RedRiverRun
in thread How to return a two dimensional array from a function in Perl? by gunners.newark

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.