in reply to Re^2: How to return a two dimensional array from a function in Perl?
in thread How to return a two dimensional array from a function in Perl?
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to return a two dimensional array from a function in Perl?
by LanX (Saint) on Nov 04, 2018 at 23:17 UTC | |
|
Re^4: How to return a two dimensional array from a function in Perl?
by AnomalousMonk (Archbishop) on Nov 05, 2018 at 03:45 UTC |