[comp.lang.perl] uudecode front-end?

richard@pegasus.com (Richard Foulk) (05/10/91)

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?

Thanks.


-- 
Richard Foulk		richard@pegasus.com

merlyn@iwarp.intel.com (Randal L. Schwartz) (05/10/91)

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'..."====/

rdm2@chaucer.uucp (25362-roe mcburnett(H053)m000) (05/15/91)

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?


Here is something that I put together that I use.  While I am reading
news, if I see something that I want to save, I use the following:

	/article/s filename:j

to find all the articles that have the same heading, save them in
"filename" and then junk the articles.

When I want to uudecode it I use:

================cut here================================
#! /d3/SWITCH/bin/perl -S
#extract will scan for uuendcoded stuff and feed it to uudecode
open(_uud,"|uudecode");
line: while (<>) {
	if(/^BEGIN/){
		$p = 'y';
		next line;
	}
	if(/^END/){
		$p = 'n';
	}
	if($p eq 'y'){
		print _uud $_;
	}
}
================cut here

As you can see there are no error checks or other embelishments.  Feel
free (but please let me know if you come up with something better.

-Roe


Roe D McBurnett III Bellcore (908)699-2273 rdm2@chaucer.cc.bellcore.com
#insert <std.disclamer>