The 'year' parameter (undef) to DateTime::new was an 'undef', which is not one of the allowed types: scalar at /usr/local/lib/perl/5.10.1/DateTime.pm line 200 DateTime::new(undef, 'year', undef, 'month', 1, 'day', 1, 'hour', 1, ...) called at smsDone line 60 #### $file_name = "sms.vmg"; tie my @array, 'Tie::File', $file_name or die("Unable to open file \"$file_name\": $!\n"); my $year = substr $array[13], 22, 8; my $month = substr $array[13], 16, 2; my $date = substr $array[13], 10, 4; my $hour = substr $array[13], 32, 4; my $minutes = substr $array[13], 38, 4; my $seconds = substr $array[13], 44, 4; $dt = DateTime->new( year=>$year, month=>$month, day=>$date, hour=>$hour, minute=>$minutes, second=>$seconds, nanosecond=>0, time_zone => 'Asia/Calcutta'); $epoch_time = $dt->epoch * 1000; print "\nEpoch Time: ".$epoch_time;