use Time::Local; # Array read from log; contains timestamps in any order: my @TIMES = ; # Sort array to get the smallest timestamp first and the largest timestamp last: sort(@TIMES); # re-arrange order to use in timelocal function: my ($year1,$mon1,$mday1,$hours1,$min1,$sec1) = ( $TIMES[0] =~ /(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+).000/ ); my ($year2,$mon2,$mday2,$hours2,$min2,$sec2) = ( $TIMES[$#TIMES] =~ /(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+).000/ ); # get timestamp in seconds since beggining of time (in unix world): $START_LAUNCH = timelocal($sec1,$min1,$hours1,$mday1,$mon1,$year1); $END_LAUNCH = timelocal($sec2,$min2,$hours2,$mday2,$mon2,$year2); # Get difference & Round off to two decimals: $TimeInMinutes = sprintf("%.2f",(($END_LAUNCH - $START_LAUNCH)/60)); return $TimeInMinutes;