in reply to File dynamic write operations
The second approach is possible in a way. The best and most comfortable solution is to use a templating library. For example Text::Template or Template::Toolkit. You write up the static text and include placeholders that the library then substitutes with anything you give it
What those templating libraries do is no secret. They just put the static text into some array and fill in the placeholders *before* writing it to a file. You can do this yourself if you want, but why reinvent the libraries
But if you literally want to first store the static data into a file and then overwrite with dynamic text, you just made your live difficult for no reason. Data in a file can't be easily shifted, so either your substitutions have the same length as the placeholders (then you might work with seek to do this) or you have to designate a character as 'ignore' character and put placeholders of maximum length into the file.
|
|---|