in reply to Extract and modify IMG SRC tags in an HTML document.
Searching and replacing HTML can be tricky. For example, what about HTML like this:
However, if you simply want to replace their picture with yours, use a regexp:<H1>Hello World</H1> <IMG HEIGHT="20" WIDTH="20" SRC="me.gif" ALT="My picture!" >
but you'll also want to remove and/or replace any WIDTH, HEIGHT, and ALT tags as well.s/SRC="[^"]*"/SRC="$mypicture"/gi;
....which get real complicated real quick. Consider using a module to parse the html, or write your own little subroutine to parse each instance of the IMG tag...
|
---|
In Section
Seekers of Perl Wisdom