title: Perl replace string (newstring oldstring)
body: <p>Implement a program that processes an input file by changing every occurrence of an old string into a new string.  (The usage is: chstr file oldstring newstring, chstr is your program name, file, oldstring and newstring are parameters specified by user.)</p>
  
  <pre><code>if( @ARGV &lt; 2)
  {    
  print "usage: ReplaceString.pl filename OldString NewString\n";
  print "   example: perl ReplaceString.pl intelliquest.txt ";
  print "IntelliQuest Kantar &gt; kantar.txt\n";
  exit 0;
  }
  $OldString = $ARGV[1];
  $NewString = $ARGV[2];
  open(MYFILE,$ARGV[0]) || die "Cannot open file \"$ARGV[0]\"";
  while($line = &amp;lt;MYFILE&amp;gt;)
  {
  $line =~ s/$OldString/$NewString/g;
  print STDOUT $line;
  }
  </code></pre>
  
  <p>really not sure what is wrong here, I try and run </p>
  
  <pre><code>jd@jd-laptop:~/Desktop$ perl HW1-2.pl text.txt if the
  </code></pre>
  
  <p>To replace if with the and i get...</p>
  
  <pre><code>syntax error at HW1-2.pl line 11, near "&amp;lt;"
  syntax error at HW1-2.pl line 11, near "&amp;gt"
  syntax error at HW1-2.pl line 15, near "}"
  Execution of HW1-2.pl aborted due to compilation errors.
  </code></pre>
  
  <p>Do i need the &amp;lt and &amp;gt?  I'm really new to Perl</p>
  
  <p>Thanks in advance </p>