<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Article 1468 of alt.sources:
Xref: feenix.metronet.com alt.sources:1468 comp.lang.perl:3680
Path: feenix.metronet.com!news.ecn.bgu.edu!mp.cs.niu.edu!ux1.cso.uiuc.edu!howland.reston.ans.net!gatech!asuvax!chnews!ornews.intel.com!ornews.intel.com!merlyn
From: merlyn@ora.com (Randal L. Schwartz)
Newsgroups: alt.sources,comp.lang.perl
Subject: Re: perl script to unpack ftpmail (and other) binaries
Date: 24 Jun 93 08:06:22
Organization: Stonehenge Consulting Services; Portland, Oregon, USA
Lines: 54
Message-ID: &lt;MERLYN.93Jun24080622@kandinsky.intel.com&gt;
References: &lt;MUTS.93Jun21205807@muts.hacktic.nl&gt;
NNTP-Posting-Host: kandinsky.intel.com
In-reply-to: muts@muts.hacktic.nl's message of Mon, 21 Jun 1993 19:58:07 GMT

&gt;&gt;&gt;&gt;&gt; In article &lt;MUTS.93Jun21205807@muts.hacktic.nl&gt;, muts@muts.hacktic.nl (Peter Mutsaers) writes:
Peter&gt; until metamail (MIME) is really common, this script might be useful to
Peter&gt; those that often use email to transmit uuencoded binaries.

Hmm.  Time for everyone to post their favorite uudecoders...

This one is really robust, being very picky about the lines it tries
to decode, and handling all sorts of weird uuencoders that do strange
things like put lowercase letters after the stuff (yuck).

================================================== snip
#!/usr/bin/perl

## Version 1.09 on 92/02/25
## Written by Randal L. Schwartz, Stonehenge Consulting Services, Portland, OR
## uudecodes the arguments (or stdin), ignoring non-uuencoded lines

shift,$debug++ if $ARGV[0] =~ /^-d/; # show lines being skipped
while (&lt;&gt;) {
	last if ($mode,$file) = /^begin\s*(\d*)\s*(\S*)/;
}
die "missing begin" unless $_;
open(OUT,"&gt; $file") if $file ne "";
while (&lt;&gt;) {
	last if /^end/;
	$u = unpack("u",$_);
	$p = pack("u",$u);
	$p =~ s/`*\n//; # toss trailing open quotes and newline
	# $p now has the shortest line that might appear in the file
	$lp = length($p);
	if (
		(!/^--/) &amp;&amp; # hack for not a cut line
		(!/^#/) &amp;&amp; # hack for not a shar tag line blech
		(!/^CREATED BY/) &amp;&amp; # hack for a stoopid losing uusplitter
		($lp &lt; length) &amp;&amp;
		(substr($_,0,$lp) =~ /^[\020-\140]+$/) &amp;&amp;
		(substr($_,$lp) =~ /^[` ]*.?.?$/) # two garbage chars ok
	) {
		print OUT $u;
		print "$_","=" x $lp, "\n" if $debug;
	} else {
		print "skipping: $_" if $debug;
	}
}
die "missing end" unless $_;
chmod oct($mode), $file;
exit 0;
================================================== snip

print "Just another Perl hacker,"
--
Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
merlyn@ora.com (semi-permanent) merlyn@kandinsky.intel.com (NEWSREADING ONLY)
Quote: "Welcome to Portland, Oregon, home of the California Raisins!"


</pre></body></html>