Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: File integrity checker

by Anonymous Monk
on Aug 24, 2017 at 17:14 UTC ( [id://1197948]=note: print w/replies, xml ) Need Help??


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

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;

Replies are listed 'Best First'.
Re^4: File integrity checker
by no_slogan (Deacon) on Aug 24, 2017 at 17:37 UTC
    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
Re^4: File integrity checker
by roperl (Beadle) on Aug 24, 2017 at 18:42 UTC
    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://1197948]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-18 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found