我正在研究2005年以来的某个程序。一直很高兴编写这样的备份:
use Storable qw(nstore_fd);
my %data =
(
"Games" => \%Games,
"Members" => \%Members,
"Scenarios" => \%Scenarios,
"Passwords" => \%Passwords,
"TourneyNames" => \%TourneyNames
);
nstore_fd(\%data, *BACKUP) or die "Can't write backup: $!";
我需要恢复一些数据。
我这样做了:
use Storable qw(fd_retrieve);
$data = fd_retrieve(*STDIN); # the backup file
print keys %{$data}, "\n";
foreach $thing (keys(%{$data})) {
print "$thing\n";
print scalar keys %{$data->{$thing}}, "\n";
}
并得到:
$ perl ~/foo.pl < BobsterBackup2018-7-9-35131.bak
GamesMembersPasswordsScenariosTourneyNames
Games
15556
Members
Can't locate object method "FIRSTKEY" via package "Hash::Case::Lower" at /Users/mgregory/foo.pl line 9.
$
我看到原始来源有:
tie %Members, 'Hash::Case::Lower'; # index by non-case-sensitive member-name.
...但是我不知所措!