Problems? Is your data what you think it is? | |
PerlMonks |
Regexps to change HTML tags/attributesby Tricky (Sexton) |
on Aug 27, 2003 at 15:49 UTC ( [id://287071]=perlquestion: print w/replies, xml ) | Need Help?? |
Tricky has asked for the wisdom of the Perl Monks concerning the following question:
Greetings Monks,
I have some simple code to read-in an HTML file to an array, remove the image and anchor tags, and write these changes to the source file on my hard-drive. So far, so good. 1. Is there a better way to initialise the variable containing the pattern? Should it be a string literal of the tag i want to remove / change? The code's below, for your perusal. Once I've read the file in , I'd like to check for the presence of the tags, and if true then call the subs which remove the tags/attributes. One of the brothers, a little while ago, thought that if I tested the patterns as they are at the moment, they would return 'true' as the value of the pattern variables were non-empty strings . Am I doing this right? 2. How may i go about testing for the presence of tags/attributes, without falling down this pit-fall? I'm also looking into how to alter the font size values of in-line styles via the same approach. Surely, there are better solutions... Trix Cheers, T update (broquaint): shifted <code> tags, added formatting and <readmore> tag
Back to
Seekers of Perl Wisdom
|
|