use strict; use Archive::Tar; my $tar = Archive::Tar->new; #read "package.tar.gz" as a compressed file $tar->read("package.tar.gz", 1); #... $file = "addfile.txt"; #not using die here to prevent the "at pack.pl line x" part open THEFILE, "<$file" or do{print "Could not open $file: $!\n"; exit 1}; #get file contents $data = {local $/ = undef; }; close THEFILE or do{print "Could not close $file: $!\n"; exit 1}; #create a file in the archive named after the original file, stored in directory pagepack. #copy the contents of the file to the archived file $tar->add_files("pagepack/$file"); $tar->add_dat("pagepack/$file", $data); #save the file as a compressed archive #This is where the checksum errors seem to appear $tar->write("package.tar.gz", 1);