http://qs1969.pair.com?node_id=1197973


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

You can shoot out one of the files in a .zip with something like this:
open my $ZIP, '+<', 'test.zip'; local $/ = undef; my $data = <$ZIP>; my @offset; while ($data =~ /PK\x03\x04/g) { # find all file headers push @offset, pos($data) - 4; } print "Found headers at: @offset\n"; substr($data, $offset[1]+14, 1) ^= "\x01"; # change the crc seek $ZIP, 0, 0; print $ZIP $data;
(This isn't foolproof, but probably good enough.) The structure of a zip file is described here: Zip (file format)#File headers