Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Re: Extracting Multiple Lines

Expand Messages
  • Paul Archer
    ... Nothing wrong with that approach. I was just saying that you can t write to the (middle of) the file without reading it in (all at once or line by line)
    Message 1 of 7 , Dec 19, 2004
    • 0 Attachment
      Friday, Stevo wrote:

      >
      > > Actually, technically this isn't true. You can seek to the middle of a file
      > > and write to it. Practically, it is, however, since you can only seek by
      > > byte offset, and not by line. So unless the file comprises only
      > > fixed-length
      > > lines, you can't really do it.
      >
      > I don't see why you couldn't write something that reads the file, line
      > by line, and writes a temporary file. Then overwrites the original.
      > Like so.
      >
      > open(ORIGFILE,"/path/to/origfile.txt");
      > open(TMPFILE,">/path/to/temp.txt");
      >
      > foreach(<ORIGFILE>) {
      > $_ =~ do something;
      > print TMPFILE "$_";
      > }
      >
      > system "mv -f /path/to/temp.txt /path/to/origfile.txt";
      >
      >
      > That might work... you just need twice the disk space as the file. Am I wrong?
      >
      Nothing wrong with that approach. I was just saying that you can't write to
      the (middle of) the file without reading it in (all at once or line by line)
      first.

      paul



      ----------------------------------------------------------------
      The wonder of all the Internet security problems is that they
      are continually labeled as 'e-mail viruses' or 'Internet worms,'
      rather than the more correct designation of 'Windows viruses' or
      'Microsoft Outlook viruses.'" --Robert X. Cringely
      ----------------------------------------------------------------
    Your message has been successfully submitted and would be delivered to recipients shortly.