title: Can I use named groups in a Perl regex to get the results in a hash?
body: <p>Is it possible to perform a named-group match in Perl's regex syntax as with Python's? I always bind the <code>$n</code> values to proper names after matching, so I'd find it more convenient to do it in the regex itself if it's possible.</p>
  
  <p>Python does it like so:</p>
  
  <pre><code>&gt;&gt;&gt; import re
  &gt;&gt;&gt; regex = re.compile(r'(?P&lt;count&gt;\d+)')
  &gt;&gt;&gt; match = regex.match('42')
  &gt;&gt;&gt; print match.groupdict()
  {'count': '42'}
  </code></pre>
  
  <p>I know the <code>?P</code> indicates that it's a Python-specific regex feature, but I'm hoping it's in Perl in a different way or was added later on. Is there any way to get a result hash in a similar manner in Perl?</p>