[lug] Perl question

Chip Atkinson catkinson at circadence.com
Mon Jun 25 17:07:34 MDT 2001


Greetings,

I'm writing a perl script to rewrite <img src=imgfile.gif> tags (as well 
as some other stuff) in html.  I want to change imgfile.gif into a name 
derived by calculating the md5sum of imgfile.gif.

Since urls and tags can span across lines, I have perl in "slurp mode" 
where I have declared { local $/;  .....}

What I think I want to do is find the img src tags and get the file name 
from a sub pattern, for example, $1 in the pattern
/<img[^>]*src\s*=\s*"([^">]*)"([^>]*)>/soig;
However, I need to use the original file name to call md5sum to get the 
new name.

Another alternative is to find a way to take the stretch of characters 
that match the pattern and remove any newlines (\n) from it.

If anyone has any suggestions on how to solve the problem, I'd 
appreciate it.

Thanks.

Chip




More information about the LUG mailing list