while (<>){ my @charpairs = /(?: \s+ (\w\w) ) /gx; if($charpairs != 4){ print "Funny looking at line $. :\n\t'$_'\n"} else{ #do smthing }}