Sylvain Aunay wrote:
> > Dear ALL> > Can someone explain to me what is wrong below : I'm trying> to pass HASH 'hash' BY REFERENCE to sub 'sub1'.> > Obviously, I didn't understand something with reference usage> (no output during sub1 execution).> > Thanks in advance> > --Sylvain> _______________________________> > sub sub1> {> my ($hashref); $hashref = @_;
Try:
my $hashref = shift;
or
my $hashref = $_[0];
You're getting the array count into hashref which is not what you want.
> print "\nsub1:\n";print %$hashref;> print $hashref->{'K1'};> }> > #Main> {> #Populate> %hash=();> $hash{'K1'}="val1";> $hash{'K2'}="val2";> $hash{'K3'}="val3";> #> print "\nMAIN:\n";print %hash;> sub1 (\%hash);> }
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles http://www.wgn.net/~dbe/
/ ) /--< o // // Mailto:d...@wgn.net http://dbecoll.webjump.com/
-/-' /___/_<_</_</_ http://www.freeyellow.com/members/dbecoll/