On 10/12/2006 10:55 AM, Gallagher, Tim F (NE) wrote:
From a subroutine I would like to return 2 separate arrays like this
sub TEST
{
@a = ("a1","a2","a3","a4","a5","a6","a7");
@b = ("b1","b2","b3","b4","b5","b6","b7");
return (@a, @b);
}
my(@lala,@baba) = TEST;
print @lala;
The problem is that @lala will return a1a2a3a4a5a6a7b1b2b3b4b5b6b7 and
@baba will return nothing. How can I return 2 arrays and have the info
look like this:
print @lala would return a1a2a3a4a5a6a7
print @baba would return b1b2b3b4b5b6b7
[...]
Return references to the arrays:
sub TEST {
my @a = ("a1","a2","a3","a4","a5","a6","a7");
my @b = ("b1","b2","b3","b4","b5","b6","b7");
return ([EMAIL PROTECTED], [EMAIL PROTECTED]);
}
my ($aref, $bref) = TEST();
print "A array: @$aref\n";
print "B array: @$bref\n";
Read the docs:
perldoc perlreftut
perldoc perllol
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>