Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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; }


Comment on Re: passing paramters to a sub
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2014-10-26 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (152 votes), past polls