I am trying to use the Date::Manip module to check the difference between the time of 2 events. I have a log file I am reading:
12:25:19 10/21/03 0 155.49.10.30 421364 1.3.6.1.4.1.11.2.3.2.3 4 0
12:25:24 10/21/03 0 155.49.10.30 421864 1.3.6.1.4.1.11.2.3.2.3 4 0
12:25:29 10/21/03 0 155.49.10.30 422365 1.3.6.1.4.1.11.2.3.2.3 4 0
12:30:19 10/21/03 0 155.49.10.30 451376 1.3.6.1.4.1.11.2.3.2.3 4 0
12:30:24 10/21/03 0 155.49.10.30 451878 1.3.6.1.4.1.11.2.3.2.3 4 0
Here is my code, using the example form the perldoc:
#!D:\perl\bin\perl
use Date::Manip;
my $log_path = "d:\\TrapRec\\TrapLog\\";
my $count=0;
open ( TRAPLOG, "$log_path\\TrapRcvr.log" ) or die ("Cannot open trap log $1" );
while (<TRAPLOG>) {
chomp;
next if $_ =~ /^\s*$/;
$count++;
($time, $date, $junk1, $ip, $junk2, $oid, $junk3, $junk4 ) = split (/\s+/);
$date1 = ("$time $date"
if ($count = 1);
$date2 = ("$time $date"
if ($count = 10);
next if ($count != 10);
$strdate=ParseDate($date1);
$enddate=ParseDate($date2);
$delta =DateCalc($strdate,$enddate,\$err);
print "$delta\n";
}
For an output, I get a long string of:
+0:0:0:0:0:0:0
What am I doing wrong?
12:25:19 10/21/03 0 155.49.10.30 421364 1.3.6.1.4.1.11.2.3.2.3 4 0
12:25:24 10/21/03 0 155.49.10.30 421864 1.3.6.1.4.1.11.2.3.2.3 4 0
12:25:29 10/21/03 0 155.49.10.30 422365 1.3.6.1.4.1.11.2.3.2.3 4 0
12:30:19 10/21/03 0 155.49.10.30 451376 1.3.6.1.4.1.11.2.3.2.3 4 0
12:30:24 10/21/03 0 155.49.10.30 451878 1.3.6.1.4.1.11.2.3.2.3 4 0
Here is my code, using the example form the perldoc:
#!D:\perl\bin\perl
use Date::Manip;
my $log_path = "d:\\TrapRec\\TrapLog\\";
my $count=0;
open ( TRAPLOG, "$log_path\\TrapRcvr.log" ) or die ("Cannot open trap log $1" );
while (<TRAPLOG>) {
chomp;
next if $_ =~ /^\s*$/;
$count++;
($time, $date, $junk1, $ip, $junk2, $oid, $junk3, $junk4 ) = split (/\s+/);
$date1 = ("$time $date"

$date2 = ("$time $date"

next if ($count != 10);
$strdate=ParseDate($date1);
$enddate=ParseDate($date2);
$delta =DateCalc($strdate,$enddate,\$err);
print "$delta\n";
}
For an output, I get a long string of:
+0:0:0:0:0:0:0
What am I doing wrong?