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

Does anyone know where I could find a module/utility/something that would let me compress things in RAR format from Perl? Either that,or a compression method that compacts better than RAR. It's the best one I know of.

Replies are listed 'Best First'.
Re: RAR compression in Perl?
by rpc (Monk) on Feb 24, 2001 at 00:42 UTC
    I would recommend Compress::Bzip2. bzip has a higher compression ratio than rar. Also, doesn't look like there are any rar modules available.

    Update: Oops, thanks grinder. Yes, this was supposed to link to CPAN.

      I was thrilled to learn that Compress::Bzip2 existed on CPAN. However, I was less than thrilled by the test script. So I wrote my own.

      0: #! /usr/bin/env perl 1: # 2: # test script for Compress::Bzip2 3: # david landgren 26-feb-2001 4: 5: use Compress::Bzip2; 6: 7: print "1..3\n"; 8: 9: my( $source, $target, $verify ); 10: 11: $source = ''; 12: $target = Compress::Bzip2::compress( $source ); 13: $verify = Compress::Bzip2::decompress( $target ); 14: 15: print 'not ' if $verify ne $source; 16: print "ok 1\n"; 17: 18: $source = 'x' x 10000; 19: $target = Compress::Bzip2::compress( $source ); 20: $verify = Compress::Bzip2::decompress( $target ); 21: 22: print 'not ' if $verify ne $source; 23: print "ok 2\n"; 24: 25: $source = do { 26: $/ = undef; 27: my $input = shift || $0; 28: if( open IN, $input ) { 29: my $slurp = <IN>; 30: close IN; 31: $slurp; 32: } 33: else { 34: ''; 35: } 36: }; 37: 38: if( !$source ) { 39: print 'not '; 40: } 41: else { 42: $target = Compress::Bzip2::compress( $source ); 43: $verify = Compress::Bzip2::decompress( $target ); 44: print 'not ' if $verify ne $source; 45: } 46: print "ok 3\n"; 47: __END__

      I've mailed the test to the author, but in the meantime if you want to use this wonderful compressor directly from Perl, with this script you'll know if it works correctly on your platform.

A reply falls below the community's threshold of quality. You may see it by logging in.