home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / tcl / 1861 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.0 KB  |  45 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!iggy.GW.Vitalink.COM!cs.widener.edu!eff!sol.ctr.columbia.edu!usc!rpi!psinntp!psinntp!sugar!karl
  3. From: karl@NeoSoft.com (Karl Lehenbauer)
  4. Subject: Re: Biff revisited
  5. Organization: NeoSoft Communications Services -- (713) 684-5900
  6. Distribution: comp
  7. Date: Tue, 17 Nov 1992 14:05:12 GMT
  8. Message-ID: <Bxv5sp.LJC@NeoSoft.com>
  9. References: <SPENCER.92Nov13055357@guraldi.med.umich.edu>
  10. Lines: 33
  11.  
  12. In article <SPENCER.92Nov13055357@guraldi.med.umich.edu> spencer@med.umich.edu
  13. (Spencer W. Thomas) posted a cool, enhanced version of the Tcl biff program
  14. posted recently.
  15.  
  16. I'd like to call attention to his use of Extended Tcl's little-known file 
  17. scanning mechanism to scan the mailbox.  
  18.  
  19. File scanning provides an awk-like ability for Tcl to read through a file, 
  20. calling Tcl code upon matching one or more patterns.  It's support for
  21. multiple scan contexts allows the code matching one pattern to scan
  22. the file for another -- it's a pain to do that sort of thing in awk.
  23.  
  24. When a match is found, the text of the line, line number (absolute if
  25. no seek has been done on the file, else line since last seek), byte
  26. position in the file and so forth are available as elements of the
  27. matchInfo array.
  28.  
  29. In Spencer's biff program, the "getheaders" proc scans the file, looking
  30. for "^From ", which will always begin a mail message in "normal" (non-MMDF
  31. and the like) mailers.  It is also looking for "From:" and "Subject:" lines,
  32. and scarfs them for the display.
  33.  
  34. Writing a Tcl mailer with this stuff wouldn't be hard, and could have some 
  35. fairly unique features, like using scanmatch you wouldn't have to read all 
  36. of the messages into memory -- you could just store the offsets into the 
  37. mail file where the messages began.  The mail file could also be updated 
  38. in place without rewriting the entire file by doing compaction, on systems 
  39. with the ftrunc system call.
  40.  
  41.  
  42. -- 
  43. -- Email info@NeoSoft.com for info on getting interactive Internet access.
  44. "Turn on your hot tub by email now.  Ask me how."
  45.