Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Collecting all values with shift

by screamingeagle (Curate)
on Aug 30, 2002 at 04:52 UTC ( #194001=note: print w/ replies, xml ) Need Help??


in reply to Collecting all values with shift

my suggestion would be to pass a reference to a hash to the subroutine; using this approach, u could pass any number of variables by just assigning a key => value to the hash, and since you're passing the hash by reference to the subroutine, you'll be able to access all the hash data inside the subroutine by simply dereferencing the hash. for example,

my %myhash = (); $myhash{'key1'} = val1; $myhash{'key2'} = val2; testsub(\%myhash); sub testsub { my $reftohash = shift; print $reftohash->{'key1'}; print $reftohash->{'key2'}; }


Comment on Re: Collecting all values with shift
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2014-09-21 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (167 votes), past polls