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

SamCG has asked for the wisdom of the Perl Monks concerning the following question:

Wise monks,

I'm looking for a way to zip files with perl. I've checked out Tie::gzip, but the documentation isn't entirely clear to me (doing the stupidly obvious cut-and-paste from the POD, and then trying to write to a file, rewards me with a "cannot modify constant item in tie" error which leads me to believe I'm misunderstanding something completely).

I could give up and use a command-line utility from perl easily enough. Trouble is, I don't really want to rely on some 3rd-party utility. Also, I like learning things, and this seems like a good opportunity ;).

Okay, I'm going to post my first attempts at test code. Try not to laugh (well, you can if you want, just don't post laughter).

#!perl -w ## Windows XP box, perl 5.8.something use strict; require Tie::Gzip; open FIL, ">C:/test.zip"; tie FIL, 'Tie::Gzip'; print FIL "This is a zipped file";

Thanks,

SamCG