title: Match positions of named capture groups in Perl's regexps
body: <p>In Perl, named capture groups can be used to extract data from a string using a regex:</p>
  
  <pre><code>perl -wle '
      use Data::Dumper;
      "abc" =~ / (?&lt;B&gt; (?&lt;A&gt; a ) b ) c /x and print "match!";
      print Dumper(\%+);
  '
  </code></pre>
  
  <p>prints </p>
  
  <pre><code>match!                                                                                                                            
  $VAR1 = {                                                                                                                         
        'B' =&gt; 'ab',                                                                                                            
        'A' =&gt; 'a'                                                                                                              
      };                                                                                                                        
  </code></pre>
  
  <p>But how do you get the <em>position</em> of the matches A and B in the string <code>"abc"</code>? When using <em>un</em>named capture groups, one can refer to the regex variables <code>@-</code> and <code>@+</code>, but this does not work for named groups (*).</p>
  
  <p>(*) With 'does not work' I mean  that I cannot use the name of the capture group to retrieve the position, but only the number of the group (e.g. <code>$-[1]</code> for the start position of group A, but not something like <code>$START_POS{A}</code>). This redicules the use of named capture groups, and may not even be possible if one does not know the order of the capture groups in advance.</p>