title: Replace a string in file with new string containing $ sign in Perl
body: <p>I am trying to replace string with a new string containing <code>$</code>(dollar) sign in a existing file. </p>
  
  <p>I have used below (regex) line in my code but I am not able get the expected result. Please suggest the solution.</p>
  
  <pre><code>system("perl -pi -e \"s/length\\s+.*/length [index $pkt_len]/g if /^\\s*set_value\\s+length/\" $filename")
  </code></pre>