develooper Front page | perl.fwp | Postings from April 2002

Re: Self extracting Perl ARchive?

Thread Previous | Thread Next
Ian Phillipps
April 1, 2002 05:53
Re: Self extracting Perl ARchive?
Message ID:
On Mon, 01 Apr 2002 at 00:55:31 -0600, Steven Lembark wrote:
> > Create a small (doesn't have to be golf), efficient, cross-platform
> > and pure Perl program to decompress the data attached via __DATA__.
> > The compression format is up to you.  tgz, tbz, zip, cpio.. whatever.
> > Just as long as it compresses decently and decompresses without a lot
> > of effort.
> How about:
> Given that gzip/pkzip/zip can all speak single-archive
> files together, we could use something like gzip/pkzip
> on a single file. We already have a decent MIME module
> that would work for combining multiple files. What about
> basically treating however many files as an "attachment"
> using standard Mime::Lite and having the perly part just
> *zip + Base64 the input, reversing it on the way out?

I'd say that wasn't "pure perl". Mime::Lite doesn't come as standard.

For this to be useful, I suggest it should work on 5.004 and up (earlier
if possible - there are installations still where "perl" gets you 4.036)
with no non-core modules. Preferably with no modules at all, to cover
cases where they have been excluded deliberately or by accident.

There's a compression method that gives about 2:1 which is used by Psion
text file readers. Very simple to decompress: my reader is attached, but
it has "require 5.00557", so is somewhat ruled out.

require 5.00557;	# For unpack 'C/a'
sub decomp {
    my ($prefix,@dict[0..255],$rest)= unpack ( 'A9'.('C/a' x 256).'A*', $_[0] );
    $rest =~ s/./$dict[ord $&]/sge;
    return $rest;

BTW, I'd be very much inclined not to use __DATA__, but to include each
file as a perl '<<' literal.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About