Subject: | ambigous call to keys() |
Hi * !
There are several calls to keys() values() and each() in Tie/SecureHash.pm. These calls are ambigous to the perl interpreter, as these functions are also defined in the same file. Even though the perl interpreter resolves these calls correctly as CORE::keys, this emits warnings (under perl -w).
Proposed fix:
Change the calls to keys() resp. each() and values() to CORE::keys() etc.
The file attached contains a patch with the proposed fix.
I hope the patch file is useful - I use it to patch my rpm-Package of Tie-SecureHash.
Regards,
Martin Kutter
--- Tie-SecureHash-1.03/SecureHash.pm 1999-11-11 04:11:06.000000000 +0100
+++ Tie-SecureHash-1.03/SecureHash.pm.patched 2004-02-03 11:25:45.000000000 +0100
@@ -240,14 +240,14 @@
return _simple_debug($_[0],$caller, $file, $line, $sub) unless $self;
my ($key, $val);
my %sorted = ();
- while ($key = each %{$self->{fullkeys}})
+ while ($key = CORE::each %{$self->{fullkeys}})
{
$key =~ m/\A(.*?)([^:]*)\Z/;
push @{$sorted{$1}}, $key;
}
print STDERR "\nIn subroutine '$sub' called from package '$caller' ($file, line $line):\n";
- foreach my $class (keys %sorted)
+ foreach my $class (CORE::keys %sorted)
{
print STDERR "\n\t$class\n";
foreach $key ( @{$sorted{$class}} )
@@ -299,14 +299,14 @@
my ($self,$caller, $file, $line, $sub) = @_;
my ($key, $val);
my %sorted = ();
- while ($key = each %{$self})
+ while ($key = CORE::each %{$self})
{
$key =~ m/\A(.*?)([^:]*)\Z/;
push @{$sorted{$1}}, $key;
}
print "\nIn subroutine '$sub' called from package '$caller' ($file, line $line):\n";
- foreach my $class (keys %sorted)
+ foreach my $class (CORE::keys %sorted)
{
print "\n\t$class\n";
foreach $key ( @{$sorted{$class}} )
@@ -318,10 +318,10 @@
}
-sub each { each %{$_[0]} }
-sub keys { keys %{$_[0]} }
-sub values { values %{$_[0]} }
-sub exists { exists $_[0]->{$_[1]} }
+sub each { CORE::each %{$_[0]} }
+sub keys { CORE::keys %{$_[0]} }
+sub values { CORE::values %{$_[0]} }
+sub exists { CORE::exists $_[0]->{$_[1]} }
sub TIEHASH # ($class, @args)
{
@@ -370,7 +370,7 @@
my ($caller, $file) = caller;
my @inaccessibles =
grep { ! eval { _access($self,$_,$caller,$file); 1 } }
- keys %{$self->{fullkeys}};
+ CORE::keys %{$self->{fullkeys}};
croak "Unable to assign to securehash because the following existing keys\nare inaccessible from package $caller and cannot be deleted:\n" .
join("\n", map {"\t$_"} @inaccessibles) . "\n "
if @inaccessibles;
@@ -387,7 +387,7 @@
sub FIRSTKEY # ($self)
{
my ($self) = @_;
- keys %{$self->{fullkeys}};
+ CORE::keys %{$self->{fullkeys}};
goto &NEXTKEY;
}
@@ -396,7 +396,7 @@
my $self = $_[0];
my $key;
my @context = (caller)[0..1];
- while (defined($key = each %{$self->{fullkeys}}))
+ while (defined($key = CORE::each %{$self->{fullkeys}}))
{
last if eval { _access($self,$key,@context) };
}