title: Assign one of multiple regex matches to variable as Perl one-liner (dereference array?)
body: <p>I already know I can print all regex matches in one go (though without separators) like this:</p>
  
  <pre><code>perl -e '$t="10 hello 25 moo 31 foo"; print ( $t =~ /(\d+)/g ) ; print "\n";'
  # 102531
  </code></pre>
  
  <p>I'm also aware I can get regex matches as named array, and then assign an individual match to a variable:</p>
  
  <pre><code>perl -e '$t="10 hello 25 moo 31 foo"; @n=( $t =~ /(\d+)/g ); $o=$n[1]; print "$o\n";'
  # 25
  </code></pre>
  
  <p>I'm also aware I could do the regex, and then refer to, say, <code>$1</code>:</p>
  
  <pre><code>perl -e '$t="10 hello 25 moo 31 foo"; $t =~ /(\d+)/g ; $o=$1; print "$o\n";'
  # 10
  </code></pre>
  
  <p>... although, for some reason, <code>$2</code> doesn't work here - why?</p>
  
  <p>What I would like to do, is assign a specific match from the regex to a variable in one go / a single line (without using the named array). Since the above tells us the results of the regex match are an array, I thought something like this idiom (used with dereferencing arrays?) would work:</p>
  
  <pre><code>$o = @{ ( $t =~ /(\d+)/g ) }[1];
  </code></pre>
  
  <p>but unfortunately it doesn't:</p>
  
  <pre><code>perl -e '$t="10 hello 25 moo 31 foo"; $o=@{ ( $t =~ /(\d+)/g ) }[1]; print "$o\n";'
  #
  </code></pre>
  
  <p>So, is there a way to achieve such a single line assignment of a regex match array in Perl?</p>