title: Perl Regex : Modification of a read-only value attempted
body: <p>I am trying to replace <code>whitespaces</code> in a string after matching it against a regular expression.</p>
  
  <pre><code>my $string = "watch download Buffy the Vampire Slayer Season 1 Episode 1 Gorillavid";
  
  if ($string =~ m!(Season\s\d+\sEpisode\s\d+)!){
  
      $1 =~ s!\s+!!g;
  
      say $1;
  
  }
  </code></pre>
  
  <p>Now when I run the above code I get <code>Modification of a read-only value attempted</code>. Now if I store the value of <code>$1</code> in a variable than try to perform a substitution on that variable it works fine.</p>
  
  <p>So, is there any way I can perform a substitution in place without creating a new temporary variable.</p>
  
  <p>PS: Can someone show me how to write the above code as one-liner because I am not able to :)</p>