There is nothing wrong with the sample you gave, there must be some other
error causing the message. And given that message it is apparently a false
message. Look for a missing colon, particularly on the previous line, or an
unclosed quote above that piece of code.
Here is a code sample doing what you are asking with no errors as a
reference:
use strict;
use Data::Dumper;
my $hashRef = foo();
my %href = %$hashRef;
$href{key1} = 'bar';
print Dumper $hashRef, "\n";
print Dumper \%href, "\n";
sub foo {
return {key1 => 'val1', key2 => 'val2'};
}
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, July 28, 2003 5:51 PM
To: [EMAIL PROTECTED]
Subject: Hash Dereferenced
I am trying to take a hash reference and then duplicate it so that I can
manipulate that data without affecting the original data. I used "my %href =
%$hashRef;" (without the quotes) to do that. $hashRef is a hash reference
that is passed into the subroutine. However, when I try to run it, I get
errors galore saying "Global symbol "%href" requires explicit package name".
Does anyone know why this is happening?
TIA
Brian
--
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]