If you do that, all the values are flattened into a single array. You should return the array references, not the arrays:return @{ $ar1 }, @{ $ar2 }, @{ $ar3 };
Of course, the calling routine has to be adapted to receive array refs, not arrays. In this case I do not see the usefulness of the data subroutine (unless I missed something). But if you want to keep it, let it also return array refs.return ($ar1, $ar2, $ar3);
Basically, the whole thing could probably be rewritten as this (untested):
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my ($test_a, $test_b, $test_c) = get_data(); print Dumper $test_a; print Dumper $test_b; print Dumper $test_c; sub get_data{ my ($ar1, $ar2, $ar3); push @$ar1, ["Acc #", "Name", "Date", "House Number",], ["1235456", "Joe More", "03/07/2010", "5",],; push @$ar2, ["", "", "","",], ["Home ", "Year", "City","",], ["", "", "","",], ["1", "2000", "Local 1","",], ["2", "2001", "Local 2 ","",], ["3", "2002", "Local 3 ","",], ["4", "2003", "Local 4 ","",], ["5", "2014", "TLocal 5 ","",], ["", "", "","",],; push @$ar3, ["", "", "","",], ["Operation:", "", "","",], ["", "", "","Name","Place", "LOC", "REF","A#1","B#2", "C#3", " +D#4",], ["", "", "","","", "", "","","", "", "",], ["", "", "","1","Mary L", "5/15/1940", "S","V","P", "-", "-",] +, ["", "", "","2","Joe T", "6/8/1990", "B","Q","X", "-", "-",], ["", "", "","3","Carl C", "07/5/1288", "A","S","Y", "-", "-",] +, ["", "", "","","", "", "","","", "", "",],; return $ar1, $ar2, $ar3; }
Update: OK, I wanted to explain too much, so that two others were faster than me by 2 minutes. ;-) Also added revised full program (untested).
In reply to Re: Returning all data from subroutine
by Laurent_R
in thread Returning all data from subroutine
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |