|Do you know where your variables are?|
Re: appending to html at beginningby Discipulus (Monsignor)
|on Feb 03, 2017 at 08:10 UTC||Need Help??|
Hello Limbomusic and welcome to the monastery and to the wonderful world of Perl!
I know nothing about what you are telling (madlibs) nor I understand the web related part (it seems a very crude type of web interaction) but if you are trying to prepend some text to an already existing file.. no there is no an automatic way to do it, as far as i know.
You need a two steps work. Between different possibilities you can work with a temporary file: you open a tempfile, you write $new_lines to it then you open the existing original file for read and write it's lines to the temp one. Finally you swap files.
Or (if your existing file is not huge) you can avoid the tempfile overwriting the original (a security copy can be handy anyway; if something go bad you can loose everything!). Something like:
PS this it is discussed in Perl FAQs: append to the beginning of a file.
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.