Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Just another Perl shrine
 
PerlMonks  

Re: Passing hashes as arguments to a sub?

by eff_i_g (Curate)
on Nov 28, 2005 at 13:11 UTC ( [id://512310]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Passing hashes as arguments to a sub?

I'm not familiar with Params::Validate that was mentioned; however, there is a simple example of being strict with hash keys in "Perl Medic." It goes something like this:
sub name { # this puts the passed list into a hash my %arg = @_; # this transfers values to variables and removes the keys my ($key1, $key2) = delete @arg{qw(key1 key2)}; # this determines if any keys are leftover croak 'Illegal arguments' if %arg; }

Replies are listed 'Best First'.
Re^2: Passing hashes as arguments to a sub?
by leocharre (Priest) on Nov 28, 2005 at 14:29 UTC
    #make hash my %junk = ( one=>'123123', two=>'dsf4f3' ) # send reference &printvals(\%junk); sub printvals { my $junk=$_[0]; #dereference these guys print $$junk{one} . $$junk{two}; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://512310]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.