Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: File integrity checker

by roperl (Beadle)
on Aug 24, 2017 at 16:49 UTC ( [id://1197943]=note: print w/replies, xml ) Need Help??


in reply to Re: File integrity checker
in thread File integrity checker

Thanks, yes the integrity check section in Archive::Zip::FAQ seems to be exactly what I need for zip files
I'm already gunzipping the gz files to a temp file name. So how do would I get the the checksum of the uncompressed file and what do I compare it to?

Replies are listed 'Best First'.
Re^3: File integrity checker
by pryrt (Abbot) on Aug 24, 2017 at 17:06 UTC

    The "checksum" is the same as the "CRC" referenced in the FAQ. The FAQ mentions example code in the CPAN distribution that shows how to calculate the CRC.

Re^3: File integrity checker
by Anonymous Monk on Aug 24, 2017 at 17:14 UTC
    IO::Uncompress::Gunzip will check the sum for you if you set the Strict option:
    gunzip 'file.gz', 'file.out', Strict=>1 or die $GunzipError;
      BTW, if you want to test your error-checking code, you can break the stored checksum like this:
      open my $F, '+<', 'file.gz' or die $!; seek $F, -8, 2; my $c = getc($F); seek $F, -8, 2; print $F chr(ord($c) ^ 1);
      Running this a second time will fix the .gz file.
        That worked great. Thanks
      Thanks that is helpful So how is
      my $retval = gunzip 'file.gz' => 'file.out', Strict=>1 or $GunzipError +;
      different than
      my $retval = gunzip 'file.gz', 'file.out', Strict=>1 or $GunzipError;
        It's not. The => operator is a "fat comma." (It also autoquotes its left-hand argument, which is why Strict=>1 doesn't produce a bareword warning.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1197943]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-03-29 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found