for( qw(row bow sow how wow crw stw wrw)) { print "$_\n"; if(/ (?(?=(.*o){1}) (?{print "there's an o!\n";}) (?(?!(.*r){1}) (?{print "there's no r!\n";}) (?=(.*w){2}) (?{print "there's two ws!\n";}) | (?{print "there's an r!\n";}) ) | (?{print "there's no o!\n";}) (?=(.*w){2}) (?{print "there's 2 ws!\n";}) (?=(.*r){1}) (?{print "there's an r!\n";}) ) ^..W$ /xi) { print "YES\n\n"; } else { print "NO\n\n"; } }