title: What does the Perl substitution operator act on?
body: <p>I have been programming in Perl, off and on, for years now, although only sporadically is it my primary language. Because I often go months without writing any perl, I rely heavily on my dog-eared Camel Book to remind me how to do things. However, when I copy recipes verbatim with no understanding, this bothers me. This is one of the most vexing: On page 154 of the 3rd edition Camel, there is an example for "modifying strings <em>en passant</em>, which reads like this:</p>
  
  <pre><code>($lotr = $hobbit) =~ s/Bilbo/Frodo/g;
  </code></pre>
  
  <p>Q1) what is going on here? On what, exactly, is the regex operating?</p>
  
  <p>Q2) Is this near-magical syntax necessary for such a basic operation as "take a string from $a, modify it with a regex, place result in $b"?</p>
  
  <p>Q3) How do I do this operation using the loop default variable as the initial string?</p>
  
  <p>Apologies in advance to Perl dreamers for whom the above looks perfectly natural.</p>