uumerge.pl

Larry Wall lwall at jpl-devvax.JPL.NASA.GOV
Tue Jul 10 12:09:26 AEST 1990


In article <3317 at tuminfo1.lan.informatik.tu-muenchen.dbp.de> rommel at lan.informatik.tu-muenchen.dbp.de (Kai-Uwe Rommel) writes:
: And this is my version for awk. It does not require all parts to be in
: separate files, the parts may be concatenated to one single file.

[Pretty little awk script deleted.]

A few little problems with the awk script:  1) I don't have nawk, and 2) it
won't handle a "-- " right after an "M" line correctly.

Also, our uudecode doesn't know what to do with file "-".

Here's my little contest entry.  It'll also handle multiple uudecodes from
a single file, as well as single uudecodes over multiple files.

#!/usr/bin/perl

while (<>) {
    if ($seq = /^begin/ .. /^end/) {
	$in = open(UU, "| uudecode"), next if $seq == 1;
	$in = 1 if /^M/ && length($_) / 10 == 6;
	$in = 0 if /^(--)?\s*$/ || /[a-z]/;
	$in = 1 if /^end/;
    }
}
continue {
    print UU if $seq && $in;
}


Or perhaps something more like this:

#!/usr/bin/perl
while (<>) {
    $inrange = /^begin/ .. /^end/;
    $valid = 1				if /^M/ && length($_) / 10 == 6;
    $valid = 0				if /^(--)?\s*$/ || /[a-z]/;
    $valid = open(UU, "| uudecode")	if $inrange == 1;
    $valid = 1				if /^end/;
    print UU if $inrange && $valid;
}

"There's more than one way to do it."

Larry Wall
lwall at jpl-devvax.jpl.nasa.gov



More information about the Alt.sources mailing list