On Fri, 2008-06-13 at 20:08 +0800, Jeff Peng wrote:

> 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};
> }
> 
> 


Hi Jeff ,

Thanks for your reply..

if we pass both array and hash to subroutine then how to retrieve  and
print the values?


Thanks

Reply via email to