jrnewquist has asked for the wisdom of the Perl Monks concerning the following question:

I have some very large plaintext chat (IRC, MUSH) logs that I would like to process into basic HTML, but with some special considerations.

Like, every time I find a certain string in the middle of a line, I want there to be a FONT tag at the beginning of the line, and a un-FONT at the end.

Or, every time the line starts with a certain string, I want to give the line some other FONT tag. ...This type of thing.

Are there any scripts out there which do this? If not, any pointers on how I can get started on writing my own?

Thanks a lot!

Replies are listed 'Best First'.
Re: Processing Chat Logs
by Chady (Priest) on Oct 01, 2002 at 20:02 UTC

    I did a small msn2html snippet... you can easily convert that to parse other type of logs.


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/
Re: Processing Chat Logs
by robartes (Priest) on Oct 01, 2002 at 21:32 UTC
    this calls for a regex or two. Something like this should do nicely:
    open LOG, "<$logfile" or die "Blerch: $!\n"; while (<LOG>) { if (/string-in-the-middle/) {print "<FONT>$_</FONT>";} if (/^string-at-the-beginning/) {print "<SOME_OTHER_FONT>$_</SOME_OT +HER_FONT>";} }

    If you want the non-matching lines as well, you'll have to dress this up a bit more.

    CU
    Robartes-