On 10/12/2006 11:23 AM, Moon, John wrote:
-----Original Message-----
From: Gallagher, Tim F (NE) [mailto:[EMAIL PROTECTED] Sent: Thursday, October 12, 2006 11:55 AM
To: Perl Beginners
Subject: Subroutine returning 2 arrays

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
Please try... sub TEST {
...
return ([EMAIL PROTECTED],[EMAIL PROTECTED])
...
}
my ($lala, $baba) = TEST;
print join(',', @$lala);
Hope this helps...

jwm


Mr. Moon, I can't tell what you wrote and what the person you're responding to wrote. Please install OE-quotefix (or Outlook-quotefix) to improve the quoting style of your posts.

http://search.yahoo.com/search?p=oe+quotefix



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to