while (<>) { if ( /^\w{5}\s\w{4}$/ ) { print "This is a 5-letter word followed by a four-letter word\n"; } }