Michael Weber wrote: ... > Pretty much accurate. The text stream looks like this: > > [Snip from /var/log/maillog] > Feb 29 16:52:01 web-2 postfix/smtpd[32047]: 6AD1EBBEF: reject: RCPT > from unknown [12.127.237.226]: 554 <alliednational.com>: Helo command > rejected: Don't spoof my hostname; from=<[EMAIL PROTECTED]> > to=<[EMAIL PROTECTED]> proto=SMTP helo=<alliednational.com> > > If I were watching my maillog file stream past, I would want to see > quickly if any messages are getting rejected. So I flag the word > "reject" in the line above to be red. So I can easily see why the > message was rejected, I would shade the string "Don't spoof my hostname" > to be ltblue.
Sounds good so far. [Except that, in the English language, there is no color "ltblue". Do you mean "light blue". There is no point in descending into the Stygian swamp of 'codes' until some existing interface demands it. Since you are planning to use escape sequences to actually feed the ANSI beast, you can use real words until you convert to those escape sequences.] > > > To do this, I create a lookup table (@color_array) with all the color > names that maps the correct terminal codes ($color) to turn on and turn > off the colorization. I have a second array (@trigger_array) that holds > the texts to look for. This is where you get lost, by sttling too quickly on an inappropriate data structure for the prupose. The problem you are working with really calls for a hash. There are a couple ways you could use hashes here. You could have one each for colors, and one for texts: my %ansi_escapes = ( 'blue' => 34, 'yellow' => 33, ... ); Since the "\033[1;" is probably constant, there is no reason to have it in the data. Things that are constant are more boilerplate than data. my %error_colors = ( 'don\'t spoof my email' => 'cyan', .... ); Then the escape sequence would be something along the lines of my $escape_sequence = $ansi_escapes{$error_colors{$error_text}}; which, IMHO, would be much simpler. Work with Perl hashes a bit, starting with some simple routines, and see how they can make such relational jobs easy. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>