home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / perl / 6945 < prev    next >
Encoding:
Text File  |  1992-11-11  |  1.3 KB  |  48 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!att-out!walter!porthos!donner!rdm2
  3. From: rdm2@donner.uucp (24337-mcburnett)
  4. Subject: Re: UUDECODE and perl ...
  5. Organization: Bellcore, Livingston, NJ
  6. Date: Wed, 11 Nov 92 21:17:03 GMT
  7. Message-ID: <1992Nov11.211703.24305@porthos.cc.bellcore.com>
  8. References: <1992Nov10.231657.17411@morwyn.uucp> <1992Nov11.134119.15928@porthos.cc.bellcore.com> <1992Nov11.150851.10057@news.eng.convex.com>
  9. Sender: netnews@porthos.cc.bellcore.com (USENET System Software)
  10. Lines: 36
  11.  
  12. In article <1992Nov11.150851.10057@news.eng.convex.com> tchrist@convex.COM (Tom Christiansen) writes:
  13. >You shouldn't have to open a pipe to uudecode.  unpack('u', $datum)
  14. >should suffice.
  15. >
  16. >--tom
  17.  
  18. Ok,  I didn't know about the 'u' option to unpack.  I submit the
  19. following.
  20.  
  21. -Roe
  22.  
  23. ================cut here================
  24. #! /usr/local/bin/perl -S
  25. #extract will scan for uuendcoded stuff and uudecode it into the right file
  26. line: while (<>) {
  27.     if(/^BEGIN/){
  28.         $p = 'y';
  29.         next line;
  30.     }
  31.     if(/^END/){
  32.         $p = 'n';
  33.     }
  34.     if(/^begin/) {
  35.         ($begin,$mode,$file)=split;
  36.         open(OUT,">$file");
  37.     } 
  38.     close OUT if(/^end/);
  39.     if( /^begin/ || /^end/ || /Subject/ ){
  40.         print stderr $_;
  41.     }
  42.     if($p eq 'y'){
  43.         print OUT unpack('u',$_);
  44.     }
  45. }
  46. Roe D McBurnett III Bellcore (908)699-2273 rdm2@chaucer.cc.bellcore.com
  47. #insert <std.disclamer>
  48.