home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.tcl
- 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
- From: karl@NeoSoft.com (Karl Lehenbauer)
- Subject: Re: Biff revisited
- Organization: NeoSoft Communications Services -- (713) 684-5900
- Distribution: comp
- Date: Tue, 17 Nov 1992 14:05:12 GMT
- Message-ID: <Bxv5sp.LJC@NeoSoft.com>
- References: <SPENCER.92Nov13055357@guraldi.med.umich.edu>
- Lines: 33
-
- In article <SPENCER.92Nov13055357@guraldi.med.umich.edu> spencer@med.umich.edu
- (Spencer W. Thomas) posted a cool, enhanced version of the Tcl biff program
- posted recently.
-
- I'd like to call attention to his use of Extended Tcl's little-known file
- scanning mechanism to scan the mailbox.
-
- File scanning provides an awk-like ability for Tcl to read through a file,
- calling Tcl code upon matching one or more patterns. It's support for
- multiple scan contexts allows the code matching one pattern to scan
- the file for another -- it's a pain to do that sort of thing in awk.
-
- When a match is found, the text of the line, line number (absolute if
- no seek has been done on the file, else line since last seek), byte
- position in the file and so forth are available as elements of the
- matchInfo array.
-
- In Spencer's biff program, the "getheaders" proc scans the file, looking
- for "^From ", which will always begin a mail message in "normal" (non-MMDF
- and the like) mailers. It is also looking for "From:" and "Subject:" lines,
- and scarfs them for the display.
-
- Writing a Tcl mailer with this stuff wouldn't be hard, and could have some
- fairly unique features, like using scanmatch you wouldn't have to read all
- of the messages into memory -- you could just store the offsets into the
- mail file where the messages began. The mail file could also be updated
- in place without rewriting the entire file by doing compaction, on systems
- with the ftrunc system call.
-
-
- --
- -- Email info@NeoSoft.com for info on getting interactive Internet access.
- "Turn on your hot tub by email now. Ask me how."
-