home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1570 < prev    next >
Internet Message Format  |  1990-12-28  |  1KB

  1. From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall)
  2. Newsgroups: comp.lang.perl,alt.sources
  3. Subject: Re: uumerge.pl
  4. Message-ID: <8662@jpl-devvax.JPL.NASA.GOV>
  5. Date: 10 Jul 90 02:09:26 GMT
  6.  
  7. In article <3317@tuminfo1.lan.informatik.tu-muenchen.dbp.de> rommel@lan.informatik.tu-muenchen.dbp.de (Kai-Uwe Rommel) writes:
  8. : And this is my version for awk. It does not require all parts to be in
  9. : separate files, the parts may be concatenated to one single file.
  10.  
  11. [Pretty little awk script deleted.]
  12.  
  13. A few little problems with the awk script:  1) I don't have nawk, and 2) it
  14. won't handle a "-- " right after an "M" line correctly.
  15.  
  16. Also, our uudecode doesn't know what to do with file "-".
  17.  
  18. Here's my little contest entry.  It'll also handle multiple uudecodes from
  19. a single file, as well as single uudecodes over multiple files.
  20.  
  21. #!/usr/bin/perl
  22.  
  23. while (<>) {
  24.     if ($seq = /^begin/ .. /^end/) {
  25.     $in = open(UU, "| uudecode"), next if $seq == 1;
  26.     $in = 1 if /^M/ && length($_) / 10 == 6;
  27.     $in = 0 if /^(--)?\s*$/ || /[a-z]/;
  28.     $in = 1 if /^end/;
  29.     }
  30. }
  31. continue {
  32.     print UU if $seq && $in;
  33. }
  34.  
  35.  
  36. Or perhaps something more like this:
  37.  
  38. #!/usr/bin/perl
  39. while (<>) {
  40.     $inrange = /^begin/ .. /^end/;
  41.     $valid = 1                if /^M/ && length($_) / 10 == 6;
  42.     $valid = 0                if /^(--)?\s*$/ || /[a-z]/;
  43.     $valid = open(UU, "| uudecode")    if $inrange == 1;
  44.     $valid = 1                if /^end/;
  45.     print UU if $inrange && $valid;
  46. }
  47.  
  48. "There's more than one way to do it."
  49.  
  50. Larry Wall
  51. lwall@jpl-devvax.jpl.nasa.gov
  52.