
PGScooter
stranger
Apr 5, 2009, 5:41 PM
Post #2 of 5
(5693 views)
|
Re: [arjunetal] Program that adds a phrase in footer of every page.
[In reply to]
|
Can't Post
|
|
Hi Arjun, You are correct- you can easily do this in Perl! There are a couple of ways you can do this: 1. process the file line by line (it's very easy, just use "open" and while (<FILEHANDLE>). Then check to see if the current line is equal to </body> (the code for this is "if ($line eq '</body>')..."). If it is, then print your header to the new file followed by the current input line; if it is not (ie, the if is false), then just print the current line to the input file. 2. you can use a "regular expression". If you do this, be sure to have the regex span over lines (there is some modifier). I apologize for not writing the script for you, but this is really an excellent opportunity for you to start learning perl!!! I would suggest option 1 because that will teach you some good techniques. You should be able to get started just by doing some googling (ie. "perl read file"). And whenever you get stuck along the way, post on this forum what you have done and where you are stuck. good luck! The more you teach me, the more I learn. The more I learn, the more I teach.
|