On Fri, Jun 13, 2008 at 7:50 PM, sivasakthi <[EMAIL PROTECTED]> wrote: > Hi all, > > how can we pass hash to subroutine? and retrieving the hash in > subroutine to print values of hash. >
Hello, Generally we use a reference. my %hash = (1,2,3,4); mysub(\%hash); sub mysub { my $hashref = shift; print $hashref->{1}; } or you could pass hash directly to a subroutine, mysub(%hash); sub mysub{ my %hash = @_; print $hash{1}; } -- Jeff Peng - [EMAIL PROTECTED] Professional Squid supports in China http://www.ChinaSquid.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/