[EMAIL PROTECTED] wrote: > > Hi: Hello,
> I'm trying Compression::Bzip2 to compress a file before upload it to > a server via ftp, but Compression::Bzip2::compress is doing the file > bigger, perldoc says: > > COMPRESSION FUNCTIONS > $dest = Compress::Bzip2::compress($string) > > Compress a string using the default compression level, > returning a string containing compressed data. > > $dest = Compress::Bzip2::compress($string, $level) > > Compress string, using the chosen compression level > (either 1 or 9). Return a string containing the com > pressed data. > > On error undef is returned. > > Even i use 1 or 9 the result is the same, double of original size, > the test code is: > > use warnings; > use strict; > use Compress::Bzip2; > > open (FIN, '/some/file'); > open (FOUT,'>/some/other/file.bz2'); > my $compressLine; > > while (<FIN>) { > print FOUT Compress::Bzip2::compress($_); #here 1, 9 or nothing > } > > close FIN; > close FOUT; > > When i use bzip2 in the command line, the result file is about mid > size, and the difference is that the block size is about 900, instead > 600 when i do it with Compression::Bzip2 You are compressing each line individually. It could be that you need to compress the whole file. use warnings; use strict; use Compress::Bzip2 'compress'; open FIN, '/some/file' or die "Cannot open '/some/file': $!"; binmode FIN; open FOUT,'>/some/other/file.bz2' or die "Cannot open '/some/other/file.bz2': $!"; binmode FOUT; my $compressLine = do { local $/; <FIN> }; print FOUT compress( $compressLine, 9 ); close FIN; close FOUT; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]