home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3372 < prev    next >
Encoding:
Internet Message Format  |  1991-05-20  |  900 b 

  1. From: subbarao@phoenix.Princeton.EDU (Kartik Subbarao)
  2. Newsgroups: comp.lang.perl,alt.sources
  3. Subject: perl version of from(1)
  4. Message-ID: <azioL/5ej/g.c@idunno.Princeton.EDU>
  5. Date: 19 May 91 23:54:24 GMT
  6.  
  7. Anyone know of a cooler way to do this?
  8. ---------
  9.  
  10. #! /usr/princeton/bin/perl
  11.  
  12. open(mail, $ENV{'MAIL'}) || exit;
  13.  
  14. while (<mail>) {
  15.     if (/^From /) {      # Note this is different from From:
  16.         chop ($out = $_); print $out;
  17.         while (<mail>) {
  18.             if (/^$/) { 
  19.                 print "\n"; 
  20.                 last; 
  21.             }
  22.             if (/^Subject:/) {
  23.                 chop;
  24.                 @subj = split(/[: ]/,$_);
  25.                 print ' "'.$subj[2].'"'."\n";
  26.                 last;
  27.             }
  28.         }
  29.     }
  30. }
  31. --
  32. internet% ypwhich
  33.  
  34. subbarao@phoenix.Princeton.EDU -| Internet
  35. kartik@silvertone.Princeton.EDU (NeXT mail)  
  36. SUBBARAO@PUCC.BITNET                      - Bitnet
  37.