DATA: while () { chomp; $_ or next DATA; # allow empty lines /(\d\d):(\d\d):(\d\d)/ or die "corrupted data at line $.: $_\n"; # but no other deviation my $hours = $1; etc.