Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: passing paramters to a sub

by rupesh (Hermit)
on Aug 30, 2005 at 05:51 UTC ( #487650=note: print w/replies, xml ) Need Help??


in reply to passing paramters to a sub



Using references is a recommended way of passing hashes to subroutines.
my %hash = ( foo => "one", bar => "two", foobar => "three", ); my %values = func(\%hash); sub func { my $h_ref = shift; my %newhash; foreach my $key (sort keys %$h_ref) { print "$key => ", $h_ref->{$key}, "\n"; $newhash{$key}=$h_ref->{$key} if $key =~ /regexp/; } return \%newhash; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://487650]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2016-12-03 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (60 votes). Check out past polls.