in reply to Slurping and s/// a group of files from a list
I would create an index file, where each imagename is mapped to an alt text-quip. 50 images times 20 pages is only 1000 items, so you can pull that index file into a hash for simplicity sake. In fact, since this is just a single-use script, don't bother with the text file, just put your filename (key) / text (value) pairs into a __DATA__ segment at the bottom of the script and read them into your hash with the <DATA> filehandle and a clever chomp and split.
Then you'll iterate over each html file in the directory. You might consider using something like HTML::TokeParser so that you don't have to roll your own (possibly less robust) regexp solution for finding the <img src... tags. As you locate each tag, match the image name with one of the hash keys, and presto, you'll have the text that needs to be added. You write out a new tempfile with the changes, and rename it over the old html file. Then move on to the next html file.
Be sure to keep backups until you've got it going right.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Slurping and s/// a group of files from a list
by ishnid (Monk) on Nov 02, 2004 at 19:52 UTC |