title: Regular expression match count in Perl
body: <p>I am matching a string of the form A&lt;=>B!C&lt;=>D!E&lt;=>F... and want to do checks on the letters. Basically I want to tell if the letters are in the class according to a hash I have defined. I had the idea of doing the following regex and then looping through the matched strings:</p>
  
  <pre><code>$a =~ /(.)&lt;=&gt;(.)/g;
  </code></pre>
  
  <p>But I can't figure out to tell how many $1, $2 variables have matched. How do I know how many there are? Also, is there a better way to do this? I am using Perl 5.8.8.</p>