Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Arrays and Scalar Parameters

by ozone (Friar)
on Aug 20, 2001 at 22:44 UTC ( #106304=note: print w/replies, xml ) Need Help??


in reply to Arrays and Scalar Parameters

You can't easily return an array and a scalar - the array is going to consume all the returned values (the scalar included).

In this case it's best to just return a ref to the array as well as the scalar like so:

sub do_something { ... return \@someValues, $someValue; } ($someValues_aref, $endValue) = do_something();
Without using references you would have to do something like this:
(@someValues) = do_something(); $endValue = pop(@someValues);
Messy, but it would get the job done.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2022-05-18 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (71 votes). Check out past polls.

    Notices?