Xref: utzoo comp.lang.perl:1770 alt.sources:2068 Path: utzoo!attcan!uunet!samsung!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl,alt.sources Subject: Re: uumerge.pl Message-ID: <8662@jpl-devvax.JPL.NASA.GOV> Date: 10 Jul 90 02:09:26 GMT References: <1990Jul7.182135.19069@alembic.acs.com> <3317@tuminfo1.lan.informatik.tu-muenchen.dbp.de> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 45 In article <3317@tuminfo1.lan.informatik.tu-muenchen.dbp.de> rommel@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@jpl-devvax.jpl.nasa.gov