you need ($hashref) = @_ otherwise you are getting the number of items being
passed vs the reference. I added and was able to print what you are looking
for. When doing passing of items to a subroutine and need to reference,
then
my( $ref1, $ref2, ...) = @_;
Wags ;}
-----Original Message-----
From: Sylvain Aunay [mailto:aun...@deltacad.fr]
Sent: Tuesday, June 27, 2000 02:00
To: Perl-Win32-Users Mailing List
Subject: Passing Hash by reference - Basic pb.
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 = @_;
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);
}
_______________________________________________
Perl-Win32-Users mailing list
Perl...@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users