dmsynck
October 23rd, 2009, 09:49 PM
Hi all,
I am a Perl newbie trying to do something beyond my current level and am having a hard time getting a regular expression correctly built. The text I am trying to match is a range of lines out of log file like so:
10/20/2009 9:59:43 AM
Time in minutes: 53
Total Number of Locations Synced: 70
Number of locations passed: 70
Number of locations failed: 0
Here is the relevant piece of my Perl script:
my $log_in_file = "C:/Logs/Synchronize_log.txt";
my $log_out_file = "C:/Logs/Synchronize_summary.txt";
open(FILE_IN, "<", $log_in_file) || die "Could not open file $log_in_file";
open(FILE_OUT, ">", $log_out_file) || die "Could not open file $log_out_file";
my @date = (localtime)[3..5];
my $current_month = $date[1] + 1;
my $current_year = $date[2] + 1900;
my @data = [];
while(<FILE_IN>) {
if(m/$current_month"//"(\d+)"//"$current_year\s*(\d+)":"(\d+)":"(\d+)\s*"AM"/ .. m/Number of locations failed:/) {
push(@data, "$_ \n");
}
}
Thanks in advance
I am a Perl newbie trying to do something beyond my current level and am having a hard time getting a regular expression correctly built. The text I am trying to match is a range of lines out of log file like so:
10/20/2009 9:59:43 AM
Time in minutes: 53
Total Number of Locations Synced: 70
Number of locations passed: 70
Number of locations failed: 0
Here is the relevant piece of my Perl script:
my $log_in_file = "C:/Logs/Synchronize_log.txt";
my $log_out_file = "C:/Logs/Synchronize_summary.txt";
open(FILE_IN, "<", $log_in_file) || die "Could not open file $log_in_file";
open(FILE_OUT, ">", $log_out_file) || die "Could not open file $log_out_file";
my @date = (localtime)[3..5];
my $current_month = $date[1] + 1;
my $current_year = $date[2] + 1900;
my @data = [];
while(<FILE_IN>) {
if(m/$current_month"//"(\d+)"//"$current_year\s*(\d+)":"(\d+)":"(\d+)\s*"AM"/ .. m/Number of locations failed:/) {
push(@data, "$_ \n");
}
}
Thanks in advance