in reply to
Modify values of tied, split lines in a file
It seems silly to create an entire new file when I could just be editing the $c variable in the input file... am I right?
IMO, probably not, for two reasons:
- Speed. Say your file is 100MB in size, your first line is "a,b,c" and you want it to be "a,b,doublec" instead. If you edit in-place, that means that everything in the file after "c" will now have to be moved 6 bytes to accomodate the extra characters, so in effect you'll be doing a 100MB write just to fix the first line. Then on the second line you'll have to move everything except the first two lines again, etc. Caching probably makes it not quite as bad as it can be, but it'll likely still be much slower than just writing a new file.
- Error recovery; if something happens while you're in the middle of processing the file, you'll end up with half a file in the new format and half in the old format. (You could of course keep track of how many lines you've converted, but you'd have to make sure to persist that value and sync the file at the same time)
So my suggestion would be to just write the new file.