title: Search and replace a particular string in a file using Perl
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6994947/how-to-replace-a-string-in-an-existing-file-in-perl">How to replace a string in an existing file in Perl?</a>  </p>
  </blockquote>
  
  
  
  <p>I need to create a subroutine that does a search and replace in file.  </p>
  
  <p>Here's the contents of myfiletemplate.txt:  </p>
  
  <pre><code>CATEGORY1=youknow_&lt;PREF&gt;  
  CATEGORY2=your/&lt;PREF&gt;/goes/here/
  </code></pre>
  
  <p>Here's my replacement string: <code>ABCD</code>  </p>
  
  <p>I need to replace all instances of <code>&lt;PREF&gt;</code> to <code>ABCD</code>  </p>