title: Why does my Perl script remove characters from the file?
body: <p>I have some issue with a Perl script. It modifies the content of a file, then reopen it to write it, and in the process some characters are lost. All words starting with '%' are deleted from the file. That's pretty annoying because the % expressions are variable placeholders for dialog boxes.</p>
  <p>Do you have any idea why? Source file is an XML with default encoding</p>
  <p>Here is the code:</p>
  <pre><code>undef $/;
  open F, $file or die &quot;cannot open file $file\n&quot;;
  my $content = &lt;F&gt;;                                           
  close F;                                                     
                                                                 
  $content =~s{status=[&quot;'][\w ]*[&quot;']\s*}{}gi;
                   
  printf $content;
  
  open F, &quot;&gt;$file&quot; or die &quot;cannot reopen $file\n&quot;;             
  printf F $content;                                           
  close F or die &quot;cannot close file $file\n&quot;;
  </code></pre>