I wrote a perl script that adds colors to text streams on the fly. It's really handy for watching log files as they run past. I watch my mail log files after making config changes and can mark "reject" in red, "spam" in blue, discard is red and my console beeps, etc. It's REALLY nice.
However, in the configuration file, the script balks if there is a blank line in it. My script reads the config file into an array before beginning to parse any data. If there is a blank line, it gives this error: Use of uninitialized value in pattern match (m//) at /usr/local/bin/filter.pl line 43, <CONF> line 10. I can probably come up with a kludge to get it to work, but what is the correct "perl" way to handle it? Here's the loop where I read in the config file: open (CONF, $ARGV[0]) || die "Can't open config file $ARGV[0], $!\n"; while (<CONF>) { @conf_line=split(","); push(@trigger_array, "$conf_line[0]"); if ( $conf_line[1] =~ "red" ) {push(@color_array, "$red")} elsif ( $conf_line[1] =~ "yellow" ) {push(@color_array, "$yellow")} elsif ( $conf_line[1] =~ "blue" ) {push(@color_array, "$blue")} elsif ( $conf_line[1] =~ "green" ) {push(@color_array, "$green")} elsif ( $conf_line[1] =~ "cyan" ) {push(@color_array, "$cyan")} elsif ( $conf_line[1] =~ "purple" ) {push(@color_array, "$purple")} elsif ( $conf_line[1] =~ "gray" ) {push(@color_array, "$gray")} elsif ( $conf_line[1] =~ "ltred" ) {push(@color_array, "$ltred")} elsif ( $conf_line[1] =~ "yellow" ) {push(@color_array, "$yellow")} elsif ( $conf_line[1] =~ "ltblue" ) {push(@color_array, "$ltblue")} elsif ( $conf_line[1] =~ "ltgreen" ) {push(@color_array, "$ltgreen")} elsif ( $conf_line[1] =~ "ltcyan" ) {push(@color_array, "$ltcyan")} elsif ( $conf_line[1] =~ "ltpurple" ) {push(@color_array, "$ltpurple")} elsif ( $conf_line[1] =~ "white" ) {push(@color_array, "$white")} elsif ( $conf_line[1] =~ "ltgray" ) {push(@color_array, "$ltgray")} elsif ( $conf_line[1] =~ "beep" ) {push(@color_array, "$beep")} else {push(@color_array, "$white")} } close (CONF); BTW. If anyone wants this script, I will re-post it after fixing this bug. I gave it as a gift to this list last year as a present for all the help I get from y'all. Thanx! -Michael -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>