Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Inserting text into a HTML file using Perl
May 18, 2007, 1:24 pm
rate this thread
I need to add the above line in each of the html files, before the
text "<\head>". All the HTML files have this text and I think some
kind of search on this string and either replacing "</head>" with the
text above and appending "<\head> to it, might be one way to do it or
just find the <\head> part and insert the text before that.
On similar lines, the text below goes towards the end. The problem is
similar to the above one and I think all that needs to be done, is
read the text below from a file, do a similar search for some text
below which this insert part should go and put it there.
var mailBody = 'Your Technical Support Team hopes this topic will
be helpful: ' + location.href;
var mailDisplay = 'Click here to email this topic.';
+ '?subject=' + escape(mailSubject)
+ '&body=' + escape(mailBody)
+ '">' + mailDisplay + '</a>'
Any ideas would be helpful. I do not know much about perl and hence
the more the better.
Thanks a lot
Re: Inserting text into a HTML file using Perl
perl -pi -e 's/search/replace/' *
If you have files in other directories, that './highlight.js' isn't
going to work, use a path relative to the document root.
And, if you have files in other directories...
perl -pi -e 's/search/replace/' `find ./ -name *.html`
Look up what that will/should do, before you run it.
Put that in a separate file, like you did with highlight.js, and use the
same technique as above.
Then, write it in a language you do know.
BTW: Searching the Internet for 'search replace perl' would
have revealed a lot of helpful code and you'd probably be
finished with this by now.
- » FAQ 5.29 How can I read a single character from a file? From the keyboard?
- — Previous thread in » PERL Discussions