#!/perl/bin/perl.exe -w use strict; my $logfile = $ARGV[0] || 'C:\WINDOWS\Eicon DIVA T-A ISDN Modem Pnp.log'; my $conn = 'Connection established'; #The string identfying a logon my $hup = 'Hanging up'; #The string identifying a hang up my (@conti, @hupti, $hours, $mins, $tot_mins, $num_con); open(INFILE, "<$logfile") or die "Error opening file: $!"; while () { #Split in mm dd yyyy hh mm ss and connect speed @conti = (split(/ |-|:|\./))[0,1,2,3,4,5,12] if (/$conn/); if (/$hup/ && $conti[5]) { @hupti = (split(/ |-|:|\./))[0,1,2,3,4,5]; $num_con++; #The number of connections $hours = $hupti[3] - $conti[3]; #Calculate hours $hours += 24 if $hours < 0; $mins = ($hours * 60) + ($hupti[4] - $conti[4]); #Calculate minutes $tot_mins += $mins; printf "%02d-%02d-%02d",$conti[1],$conti[0],substr($conti[2],2); #Date printf " %02d:%02d:%02d Connected for ",$conti[3],$conti[4],$conti[5]; #Time printf "%04d minutes ",$mins; printf "at %09s\n",$conti[6]; undef @conti; } } close INFILE; print "\nTotal number of connects: "; printf "%04d \n",$num_con; print "Total connect time: "; printf "%06d minutes \n",$tot_mins; print "Average connect time: "; printf "%02d minutes \n", $tot_mins/$num_con;