develooper Front page | perl.beginners | Postings from February 2002

Return multiple arrays

Thread Next
From:
Mike Garner
Date:
February 5, 2002 07:52
Subject:
Return multiple arrays
Message ID:
5.1.0.14.0.20020205084318.00a982a8@mail.western.edu
I'm going back through some old code and trying to clean things up, apply 
new tricks, and make sure everything is running in strict mode.  Doing this 
I have encountered a problem.  I have a subroutine that calls another 
subroutine, passing one array to the second for processing.  I need the 
second sub to return 3 arrays to the first sub.  I can't seem to get this 
to work....well I can return the data from all three subs, but it returns 
into one array.  Is there an option to do this or do I need to rewrite the 
second subroutine into 3 smaller subs? or maybe I'm not using my 
correctly...running without use strict; and not using my on the arrays 
makes them global and avaiable for processing by the first sub...but I want 
to use strict;

sub sub1 {
   my (@array1,@array2,@array3,@array4);
   (@array2,@array3,@array4)=&sub2(@array1);
   dosomething;
}

sub sub2 {
   my(@array5,@array6,@array7,@array8);
   @array5=@_;
   do three processes with @array5 and store results in arrays 6-8;
   return(@array6,@array7,@array8);
}

--------------------------------------------------------------
Mike Garner
Western State College
Email: mgarner@western.edu
Voice: 970-943-3123
Fax: 970-943-7069


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About