Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Answer: How do I pass more than one array or hash to a subroutine

( #349754=categorized answer: print w/ replies, xml ) Need Help??

Q&A > subroutines > How do I pass more than one array or hash to a subroutine contributed by hossman

If you declare your subroutine with a function prototype specifying each argument as \% or \@, then your method will automatically get a reference to the hashes/arrays passed to it, without the person calling the function/method/subroutine needing to do anything special.

Note that, like all prototypes, this doesn't work when calling the subroutine using & or as a method.

See the 'Prototypes' section of perlsub for more details, or this node for a good example.

Comment on Answer: How do I pass more than one array or hash to a subroutine
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2015-07-05 14:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls