Michael Weber wrote:
>
> 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(",");
This should work:
my @conf_line = split /,/ or next;
> push(@trigger_array, "$conf_line[0]");
^ ^
You don't need to convert $conf_line[0] to a string, it already is a
string!
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>