Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Returning two lists from a sub

by philcrow (Priest)
on Jun 07, 2007 at 13:23 UTC ( [id://619805]=note: print w/replies, xml ) Need Help??


in reply to Returning two lists from a sub

You need to use references to avoid the flattening you noticed:
my ($a, $b) = getarrayrefs(); print join(" ", @{ $a }), "\n", join(" ", @{ $b }); sub getarrayrefs { my @foo = (1,2,3); my @bar = (4,5,6); return \@foo, \@bar; }
Phil

Update: Corrected sub name to match call. Thanks Albannach.

The Gantry Web Framework Book is now available.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://619805]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-29 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found