/usr/share/perl5/Module/CoreList/TieHashDelta.pm is in libmodule-corelist-perl 5.20170120-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | # For internal Module::CoreList use only.
package Module::CoreList::TieHashDelta;
use strict;
use vars qw($VERSION);
$VERSION = '5.20170120';
sub TIEHASH {
my ($class, $changed, $removed, $parent) = @_;
return bless {
changed => $changed,
removed => $removed,
parent => $parent,
keys_inflated => 0,
}, $class;
}
sub FETCH {
my ($self, $key) = @_;
if (exists $self->{changed}{$key}) {
return $self->{changed}{$key};
} elsif (exists $self->{removed}{$key}) {
return undef;
} elsif (defined $self->{parent}) {
return $self->{parent}{$key};
}
return undef;
}
sub EXISTS {
my ($self, $key) = @_;
restart:
if (exists $self->{changed}{$key}) {
return 1;
} elsif (exists $self->{removed}{$key}) {
return '';
} elsif (defined $self->{parent}) {
$self = tied %{$self->{parent}}; #avoid extreme magic/tie recursion
goto restart;
}
return '';
}
sub FIRSTKEY {
my ($self) = @_;
if (not $self->{keys_inflated}) {
# exceeds the warning limit of 100 calls since 5.23.2
no warnings 'recursion';
# This inflates the whole set of hashes... Somewhat expensive, but saves
# many tied hash calls later.
my @parent_keys;
if (defined $self->{parent}) {
@parent_keys = keys %{$self->{parent}};
}
@parent_keys = grep !exists $self->{removed}{$_}, @parent_keys;
for my $key (@parent_keys) {
next if exists $self->{changed}->{$key};
$self->{changed}{$key} = $self->{parent}{$key};
}
$self->{keys_inflated} = 1;
}
keys %{$self->{changed}}; # reset each
$self->NEXTKEY;
}
sub NEXTKEY {
my ($self) = @_;
each %{$self->{changed}};
}
1;
|