in reply to Re^2: How do I modify a line within the file itself?
in thread How do I modify a line within the file itself?
I thank you for the examples
Wow, that's a lot of code. The whole purpose of using an external library is to reduce how much code you have to write!
Didn't you notice the reduction? There is no 3 argument open , no "or die" verbosity? I think thats neat
... edit_file_lines .... neat, huh? For an in-place edit, that's the way to go.
Did you know that reads the whole file into memory? It limits the size of files you can edit to the amount of RAM you have (and perl has access to)
That /\>/ hints to me the OP might be dealing with gigabyte sized files, probably a good idea to avoid slurping
When I need to do something more with the lines in the file, I usually skip the full monty and go with File::Slurp::Tiny, but in this case that takes a little more coding since you have to build up an array to pass to its write_file method, and you need to create an output file:
That has the same issue, it read whole file into memory/an array, duplicate this array, write it out ; Too much memory requirement based on size of file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How do I modify a line within the file itself?
by 1nickt (Canon) on Jul 09, 2015 at 10:26 UTC |