Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return multiple arrays

Status
Not open for further replies.

jgiri

Programmer
May 9, 2010
6
0
0
US
I am having trouble returning multiple arrays from sub. I am returning arrays like this: return (@allhosts,@allips); and calling sub like this:
my (@data , @allips) = getfarmdetails($farmid,$name);

However it seems that first array has everything, am I not doing this right ?
 
You're going to have to return them as references.
 
Like rharsh says, return them as references, so you will get an array of two references returned, each pointing to an array.
Perl:
return (\@data, \@allips);
If you have any problems with what the data looks like, use Data::Dumper to help you visualise it.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top