Think about Loose Coupling | |
PerlMonks |
Tie::File insertion problemby Flubb (Acolyte) |
on Jan 31, 2008 at 15:43 UTC ( [id://665372]=perlquestion: print w/replies, xml ) | Need Help?? |
Flubb has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I have a script which needs to insert a line into an html file after a certain point (ie, at the beginning of the html file.) We have a build system that I want take results from and present the most recent results first. The script looks like: (I've redacted redundant information) I've been following a previous answer: http://www.perlmonks.org/?node_id=155567 What I thought the script was going to do Go to the file on the server and open it into an array Search for the pattern that begins with <th>PC Number... and then after that line, insert my line <td><a href... What is actually happening is that the contents of the html get copied repeatedly every time the script is run, so I get two copies of the contents, rather than the 1 line added I thought I was going to get. It finds the <th>PC Number</th> but then tacks the entire contents of the file onto the end of that line. The html code is simply the following:
And then my script is supposed to add things to the top of the file. Can anyone enlighten me why it's not doing what I thought it would?
Back to
Seekers of Perl Wisdom
|
|