title: perl: Writing file at Nth position
body: <p>I am trying to write in to file at Nth POSITION. I have tried with below example but it writes at the end. Please help to achieve this.</p>
  
  <pre><code>#!/usr/bin/perl
  
  open(FILE,"+&gt;&gt;try.txt")
  or
  die ("Cant open file try.txt");
  
  $POS=5;
  
     seek(FILE,$POS,0);
  
     print FILE "CP1";
  </code></pre>