COLLINEAU writes:
> How can i do to delete the last line of a file ?

>From perlfaq5...

     How do I change one line in a file/delete a line in a
     file/insert a line in the middle of a file/append to the
     beginning of a file?

     <snip>

     In the unique case of deleting lines at the end of a file,
     you can use tell() and truncate().  The following code
     snippet deletes the last line of a file without making a
     copy or reading the whole file into memory:

             open (FH, "+< $file");
             while ( <FH> ) { $addr = tell(FH) unless eof(FH) }
             truncate(FH, $addr);

     Error checking is left as an exercise for the reader.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to