- To: Michael Lake <Mike.Lake@xxxxxxxxxx>
- Subject: Re: [SLUG] Perl Q
- From: Dean Hamstead <zort@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed Jul 12 14:05:32 2000
- Cc: slug@xxxxxxxxxxx
- Organization: PCL
- Reply-to: dean@xxxxxxxxxxxxxxxxxxxxxx
an option could be to split it up....
my(@A) = readData('a');
my(@B) = readData('b');
sub readData
{
if ($_ eq 'a') { return @A;};
if ($_ eq 'b') { return @B;};
};
i think $_ might be @_
but you get the point
Dean
Michael Lake wrote:
>
> Hi,
>
> Simple Q,
>
> My perl script has a function and I want to return two
> arrays from the function. I found that I can't just assign
> the return values like this;
>
> (@A, @B) = readData();
>
> sub readData
> {
> # get data and create @A and @B
> return (@A, @B);
> }
>
> My perl book doesn't cover returning more than one array. Do
> I use references? I don't want to put A and B into a single
> array and return that then later have to separate out A and
> B.
>
> The perl script runs on my Linux box here via apache and is
> part of the new computer based chemistry experiment for this
> semester coming up.
>
> Mike
> --
> --------------------------------------------------------------------
> Michael Lake
> University of Technology, Sydney
> Email: mailto:Mike.Lake@xxxxxxxxxx Ph: 02 9514 1724 Fx: 02
> 9514 1628
> URL: http://www.science.uts.edu.au/~michael-lake/
> Linux enthusiast, active caver and interested in anything
> technical.
> --------------------------------------------------------------------
>
> --
> SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
> More Info: http://slug.org.au/lists/listinfo/slug