use Time::Local; ... my $ref = shift; my $date1 = shift @$ref; my $time1 = shift @$ref; print "-1\n" and exit unless $date1 =~ /(\d\d)(\d\d)(\d\d)/; my @date2 = ($1,$2,$3); print "-1\n" and exit unless $time1 =~ /(\d\d):(\d\d)/; my @time2 = ($1,$2); my $t; eval {$t = timegm(0,$time2[1],$time2[0],$date2[1],$date2[0]-1,$date2[2]+100)}; print "-1\n" and exit if $@; ...