i must be missing the point, but why are you using prototyped subroutines to populate a hash ref?
what's wrong with: my $href = { foo => 'quux', bar => [ qw( bleh yuck) ], }; or $href->{'baz'} = { foo => 'bar' } ? regards, Jos ----- Original Message ----- From: "Ross Howard" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 18, 2001 3:33 PM Subject: symbolic reference of hashes in subroutines > I figured this one out using the camel book and brute force methods. But if > anyone could shed some light on symbolic references of the hash arrays I > would appreciate it. > > Specifically, in the subroutine below populate_hash(), the line: > ${%{$hash}}{$key} = $value; > Seems kind of ugly saying heres a reference, really it's a hash, go ahead > and put a new key/value pair in, cause I know it's a hash. > > Is this the correct way of doing this? > > Thanks in advance, > Ross > > #!/usr/local/bin/perl -w > > # Undefining the variables to be used as hash array > undef $hash1; > undef $hash2; > > # Insertting some values just to start things off > $hash1{KEY0} = "value0"; > $hash2{DOWAP} = "DOWAH"; > > # Populating each hash with more values using a subroutine > populate_hash (\%hash1, "HEY1", "value1"); > populate_hash (\%hash2, "HUMM", "HAH"); > > # Outputting the hash contents for first array > foreach $key (keys %hash1) { > print "hash1 $key -> $hash1{$key}\n"; > } > > # Outputting the hash contents for second array > foreach $key (keys %hash2) { > print "hash2 $key -> $hash2{$key}\n"; > } > > exit; > > # Simple subroutine to populate a passed hash array with values > sub populate_hash ($$\%) { > my $hash = $_[0]; > my $key = $_[1]; > my $value = $_[2]; > > ${%{$hash}}{$key} = $value; > } > > > > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]