Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!mips!pacbell.com!att!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal L. Schwartz) Newsgroups: comp.lang.perl Subject: Re: uudecode front-end? Message-ID: <1991May10.160619.18398@iwarp.intel.com> Date: 10 May 91 16:06:19 GMT References: <1991May10.041629.4942@pegasus.com> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal L. Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 36 In-Reply-To: richard@pegasus.com (Richard Foulk) In article <1991May10.041629.4942@pegasus.com>, richard@pegasus (Richard Foulk) writes: | Anyone have a fairly robust uudecode front-end? Something you can | give a multi-part posting to and have it remove the cruft before | sending it to uudecode? I use "uumerge", based in part on an example in The Book. It's not a uudecode front end... it does the whole decode right inside Perl, thanks to unpack('u'). Here: ################################################## snip #!/usr/bin/perl while (<>) { $sawbegin++, last if ($mode,$file) = /^begin\s*(\d*)\s*(\S*)/; } die "missing begin" unless $sawbegin; open(OUT,"> $file") if $file ne ""; while (<>) { $sawend++, last if /^end/; s/[a-z]+$//; # handle stupid trailing lowercase letters next if /[a-z]/; next unless int((((ord() - 32) & 077) + 2) / 3) == int(length() / 4); print OUT unpack("u", $_); } die "missing end" unless $sawend; chmod oct($mode), $file; exit 0; ################################################## snip print unpack("u",pack("h*", <<'-- ')) 9323745335d3221214b364d545a362532582521254c3640504a3625234a3655325b2060606a0 -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/