in reply to Re^4: How to delete a particular line in a text file after some operation on that text file at the same time
in thread How to delete a particular line in a text file after some operation on that text file at the same time
The output of your code will be done in another file. But i want to do it in same.
It's the same as in any other programming language:
On a sheet of paper, you can use whiteout, but then there will remain a visible gap. If you don't want that, you have to rewrite (i.e. copy) the complete sheet.
In Perl (or C, or whatever) , you could overwrite with the same number of bytes, e.g. spaces, but if you want to avoid the gap, you have to copy the whole thing into a new file and then do the "delete and rename" dance. That's what most editors and word processors do.
Tie::File (see GotToBTru's reply) internally does, so to say, use the whiteout/overwrite approach and rewrites all subsequent lines "in place".
|
|---|