Hello,
In the following script my goal is pull the date value each time an error value
(hardcoded) is found in the specified log file. The script retrieves the error
value without a problem but I cannot seem get the date value. Can anyone tell
me what I need to do?
The error message when I run the script is:
Use of uninitialized value in concatenation (.) or string at script.pl line 32
where line 32 is where I am calling this:
"print $date";
Here is the script:
use warnings;
use strict;
#Specify the path to the log file you want to read, for ex. application log#
open (FILEHANDLE, 'd:/scripts/server2.log') or print "Can't Open File!!!";
while(( my $line = <FILEHANDLE>)) {
#Searching for keywords from application log#
if (($line =~ m/CQCommitException/i ) || ($line =~ m/Communication link
failure/i)) {
my @fields = split '\|', $_;
my $date = $fields[1];
print $date;
#prints $line to file
open (my $outfile, ">>", "d:/scripts/loginfo.txt") or die "Can't open
loginfo.txt: $!";
print $outfile "$date, $_\n";
#close $outfile or die "$outfile:$!";
}
}
my $outfile = 'd:/scripts/loginfo.txt';
#To send or not to send - file size check
#Delete file when done
#unlink 'd:\scripts\loginfo.txt';
-END-
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/