Hi I am trying to save a hash reference in file named 'chksum' and retrieve it later when needed. But it gives me an error.
Test.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';
Output
root@- [~/ftp_kasi]# perl test.pl
Not a HASH reference at test.pl line 25.
Can somebody help me out on this. Thanks in advance.