while (<>) { # Only require a non-null first capture if (/(\w\w)(\w\w)?(\w\w)?(\w\w)?/) { # Do something } }