in reply to Comedy of StdErrs

I'm not sure I understand your question. The most common way to print a message and exit is with die:

$date1 =~ /(\d\d)(\d\d)(\d\d)/ or die "Invalid date format"; $time1 =~ /(\d\d):(\d\d)/ or die "Invalid time format";

Or are you talking about catching the error from gmtime? You're doing that properly, and I don't believe there's a better way to do it. When I have code like this, I will often wrap the entire thing in an eval, like this:

eval { my $ref = shift; my $date1 = shift @$ref; my $time1 = shift @$ref; die unless $date1 =~ /(\d\d)(\d\d)(\d\d)/; my @date2 = ($1,$2,$3); die unless $time1 =~ /(\d\d):(\d\d)/; my @time2 = ($1,$2); my $t; $t = timegm(0,$time2[1],$time2[0],$date2[1],$date2[0]-1,$dat +e2[2]+100)}; }; print "-1\n" and exit if $@;
It consolidates the error handling better.