On Jan 16, Karthik Gurumurthy said:
>($a,$b,$c) = (\"1",\"2",\"3");
>
>%hash = ($a=>"hello",$b=>"Perl");
You cannot use references as the keys to a hash, because hash keys must be
strings.
If you're REALLY desperate, you can use Tie::RefHash, but I don't think
you should be so desperate.
--
J
hi!
this is a simple program i wrote to understand references..
($a,$b,$c) = (\"1",\"2",\"3");
%hash = ($a=>"hello",$b=>"Perl");
foreach $key (keys%hash){
$keyval = ${$key};
print "$keyval\n";
print ("The key is $$key and the value is $hash{$key}\n");
}
the output is: