<div><div>Of course, if you're not going to use backreferencing ($1, $2, etc) with those parens, you'll probably want to turn off the backreferencing with ?: inside the parens; no need to create backreferences if you're not going to use 'em: 
<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">foreach (qw(AAXXBB AAYBB AAXYBB AAYBB AYBB)) {<br>&nbsp;&nbsp; printf(&quot;%-7s&quot;, $_);
<br>&nbsp;&nbsp; print (($_ =~ /^AA(XX|Y)BB$/) ? &quot;yes&nbsp;&nbsp;&quot; : &quot;no&nbsp;&nbsp; &quot;);<br>&nbsp;&nbsp; print (($_ =~ /^AAXX|YBB$/)&nbsp;&nbsp; ? &quot;yes&nbsp;&nbsp;&quot; : &quot;no&nbsp;&nbsp; &quot;);<br>&nbsp;&nbsp; print &quot;\n&quot;;<br>}<br><br>$ perl j.pl<br>AAXXBB yes&nbsp;&nbsp;yes
<br>AAYBB&nbsp;&nbsp;yes&nbsp;&nbsp;yes<br>AAXYBB no&nbsp;&nbsp; yes<br>AAYBB&nbsp;&nbsp;yes&nbsp;&nbsp;yes<br>AYBB&nbsp;&nbsp; no&nbsp;&nbsp; yes</blockquote><div><br>$ cat x.pl<br><br>foreach (qw(AAXXBB AAYBB AAXYBB AAYBB AYBB)) <br>{<br> &nbsp; printf(&quot;%-7s&quot;, $_);<br> &nbsp; print (($_ =~ /^AA(?:XX|Y)BB$/) ? &quot;yes &nbsp;&quot; : &quot;no &nbsp; &quot;);
<br> &nbsp; print (($_ =~ /^AAXX|YBB$/) &nbsp; ? &quot;yes &nbsp;&quot; : &quot;no &nbsp; &quot;);<br> &nbsp; print &quot;\n&quot;;<br>}&nbsp;</div><br>AAXXBB yes&nbsp; yes<br>AAYBB&nbsp; yes&nbsp; yes<br>AAXYBB no&nbsp;&nbsp; yes<br>AAYBB&nbsp; yes&nbsp; yes<br>AYBB&nbsp;&nbsp; no&nbsp;&nbsp; yes<br><br>
<br>-- b<br><br></div>