title: Why does my Perl script delete the contents of whole file when I try to edit the file?
body: <p>I am running the following code to open a file (test) and edit(search and replace) it. Program seems to open the file but instead of replacing it deletes everything in the file. I am not sure why that is happening. Can anyone help me out here? </p>
  
  <pre><code>#!use/bin/perl
  use strict;
  use warnings;
  
  my $line = $ARGV[0];
  my $find = '\s{6}seqfile\s=\sinfile';
  my $replace = '\s{6}seqfile\s=\sinfil2';
  
  open (FILE, "&gt;/home/shubhi/Desktop/pamlrun/test") || die "cant open file \n";
  my @body = &lt;FILE&gt;;
  foreach $line(@body)
  {
  (s/$find/$replace/g);
  {
  print FILE "$line";
  }
  }
  close(FILE);
  print "reached here\n";
  exit;
  </code></pre>