title: Perl seek function
body: <p>This problem was solved. Thank you very much.<br>
  My question and the solution I am using is stated below.<br><br>
  Question:</p>
  
  <pre><code>open IN, "&lt;./test.txt";
  seek(IN,10,0);
  read IN, $temp, 5;
  
  seek(IN,20,0);
  close(IN);
  </code></pre>
  
  <p><br>
  The situation is that, my handle will start at position 0.<br>
  After the first seek function, my file handle will at position 10.<br>
  After I read, my handle will at position 15.<br>
  At this moment, I seek again. Then the program will seek from the beginning or from position 20.<br>
  My question is that is there anyway for me to do searching in a file so that I do not need to search from the starting point of the file every time?<br>
  <br><br></p>
  
  <p>The way I am using:<br><br></p>
  
  <pre><code>use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END); #SEEK_SET=0 SEEK_CUR=1 ...
  
  $target_byte=30;
  open IN, "&lt;./test.txt";
  seek(IN,10,SEEK_SET);
  read IN, $temp, 5;
  
  $position=tell(IN);
  seek(IN,$target_byte-$position,SEEK_CUR);
  #do what I want
  close(IN);
  </code></pre>