#!/usr/bin/perl use strict; use warnings; #Using perl package use Date::Calc qw(Delta_YMDHMS); use Date::Calc qw(Add_Delta_DHMS); #subroutine: rounding no sub round($); while () { my @line=split(";"); my @start_time=($line[3]=~/(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+)/); #parsing the start time my @stop_time=($line[4]=~/(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+)/); #parsing the stop time my @diff=Delta_YMDHMS(@start_time,@stop_time); #calculate diff in YMDHMS my($yyyy,$m,$d,$hh,$mm,$ss)=@diff; $min_diff=($yyyy*365*24*60+$m*30*24*60+$d*24*60+$hh*60+$mm*1+$ss*0); #convert to mins $interval=round($min_diff/15); #get the interval print "minutes difference between two dates are: $min_diff"; } sub round($) { my($number) = shift; return int($number + .5); }