On Sun, 2004-11-28 at 04:09 +0100, Gunnar Hjalmarsson wrote: > Dan Jones wrote: > > > > local $/ = "\n\nFrom "; > > > > $_ = <MAILBOX>; > > $_ =~ s/\n\nFrom $//; > > ProcMessage($_); > > > > while(<MAILBOX>) { > > $_ =~ s/\n\nFrom $//; > > ProcMessage("From $_"); > > > > if(Pause() == 0) { > > last; > > } > > } > > > > close MAILBOX; > > > > sub ProcMessage($){ > > my $message = shift; > > print "Message:\n $message \n\n"; > > } > > Seems fine to me. The only concern is paragraphs that start with > "From ", without e.g. ">" being prepended to those lines. I suppose you > know whether that is an issue to count with.
That isn't supposed to happen. The program writing to the mailbox is responsible for checking for that and appending a ">" to those lines. See here if you're interested: http://en.wikipedia.org/wiki/Mbox On to the next issue. One of the things I want to do is to check for duplicate messages. The common way to do that is to simply check the Message ID. The widely used procmail recipe uses that method, as does the formail utility. However, Message IDs are not guaranteed to be unique. If a collision does occur, you lose a message. My thought is to hash the message body, and store that hash value. If a Message ID collision occurs as you're processing the mailbox, you check the hash values to be sure they're the same before deleting the message. The problem is that Perl has a variable type called "hash." (Yes, I know, you probably heard that somewhere before.) Searching for information on using hashing functions in Perl leads to pages and pages of information dealing with the hash variable type. Perl obviously uses an internal hashing function to generate its hash variables. Is it possible to access that function from a script? If not, does anyone know of a module or pointer to information on hashing functions for Perl? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>