您好我正在尝试将哈希引用保存在名为“chksum”的文件中,并在以后需要时检索它。但这给了我一个错误。
测试.pl
#!/usr/local/cpanel/3rdparty/bin/perl
use Storable;
use File::Find qw(find);
use Digest::MD5 qw(md5_base64);
use Data::Dumper;
#=head
######################
#Collect checksum #
######################
my $files = {};
$files_ref = retrieve('checksum');
find(sub {
my $file = $File::Find::name;
return if ! length($file);
my ($size, $mtime) = (stat $_)[7, 9];
open (FILE, $file);
$chksum = md5_base64(<FILE>);
$files->{$file} = {
local_is_dir => (-d _ ? 1 : 0),
local_size => $size,
local_mtime => $mtime,
chksum => $chksum,
};
#$ref = $files->{$file} || = {};
my $ref = $files_ref->{$file} ||= {};
if ($chksum != $ref->{chksum}) {print $file;}
}, '/root/ftp_kasi/');
#print Dumper(\$files);
store \$files, 'checksum';
输出
root@- [~/ftp_kasi]# perl test.pl
Not a HASH reference at test.pl line 25.
有人可以帮我解决这个问题。提前致谢。