Alright this one has had me stumped to long.
I've been searching through "Programming Perl (3rd ed.)," but
have had no luck. It seems like my references are getting
converted to strings against my wishes. Can someone
tell me where and why this is happening and how to stop/avoid it?
I'm getting the following error
-------------------------------
Can't use string ("SCALAR(0x80cd828)") as a SCALAR ref while "strict
refs" in use at ./smalltest.pl line 25.
In the following code
-------------------------------
#!/usr/bin/perl
use strict;
# values are the same, can't use them as keys
my $word = "initial";
my $num = "initial";
# the references are unique, use them as keys
my $wordref = \$word;
my $numref = \$num;
# create hash
my %hash = (
$wordref => "one",
$numref => "two"
);
# output should look like:
# keyval = initial
# keyval = initial
# get the values agian
foreach my $key (keys %hash) {
print "keyval = ", ${$key}, "\n";
}
Thanks,
Michael