if ($hansLine =~ /\A HANS \D* 9999 (\d{3}) /x) { # ... }