title: Why are there parentheses around scalar when assigning the return value of regex match in this Perl snippet?
body: <p>I wrote the following regex in order to get the digits from a string:</p>
  
  <pre><code>my ($digits) = ($str =~ /(\d+)/);
  </code></pre>
  
  <p>It works as expected but I was wondering why I need to use parentheses around <code>$digits</code>? Why doesn't it work without the parenthesis? I tried to find some information about it on the web but didn't find any.</p>
  
  <p>Why can I use it like this:</p>
  
  <pre><code>my $digits = ($str =~ /(\d+)/);
  </code></pre>
  
  <p>Can I make the changes on the <code>$str</code>? something like this: <code>$str =~ /(\d+)/;</code>?</p>