in reply to Slurping and s/// a group of files from a list

You can do this from the command line (this started out being fairly straightforward and ended up being pretty convoluted so it's obviously not the best solution as far as clarity goes, maybe not for performance either):
perl -pi'.orig' -e 'BEGIN {open(FH,"alt_tag_file"); @alltags = <FH>; c +homp @alltags;}; @tags = @alltags unless(scalar(@tags)); s/(<img)([^> +]+>)/@T = ($1,$2); $T[0].($T[1] =~ m,\balt=, ? "" : q{ alt="}.shift(@ +tags).q{"}).$T[1]/eg *.html *.htm *.shtml
All your original files will be renamed to be something like foo.html.orig (use perl -pi -e if you don't care about backups).

I might be misunderstanding the OP's desired solution (based on davido's response) but this solution assumes that you don't need to match up image names to alt tags (the alt tags are in the correct order in the alt tag file)
--Brian

Replies are listed 'Best First'.
Re^2: Slurping and s/// a group of files from a list
by davido (Cardinal) on Nov 02, 2004 at 19:19 UTC

    The OP did imply that the alt tags would be in order in the tag file. I was just making the point that I wouldn't do it that way, but rather, would use a hash to map image names to tags. And the reason is that if you miss-order just one item in the text list, you'll end up screwing up the whole thing. What a mess that could be. Imagine the image of a puppydog showing up with the text for a cat! But even worse, imagine every image past that point also being screwed up.;)

    Your method works fine too... as long as there are no mistakes when creating the image alt text file.


    Dave