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: References: NNTP-Posting-Host: kandinsky.intel.com In-reply-to: muts@muts.hacktic.nl's message of Mon, 21 Jun 1993 19:58:07 GMT >>>>> In article , muts@muts.hacktic.nl (Peter Mutsaers) writes: Peter> until metamail (MIME) is really common, this script might be useful to Peter> 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 (<>) { last if ($mode,$file) = /^begin\s*(\d*)\s*(\S*)/; } die "missing begin" unless $_; open(OUT,"> $file") if $file ne ""; while (<>) { 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 ( (!/^--/) && # hack for not a cut line (!/^#/) && # hack for not a shar tag line blech (!/^CREATED BY/) && # hack for a stoopid losing uusplitter ($lp < length) && (substr($_,0,$lp) =~ /^[\020-\140]+$/) && (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!" .