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

Yes, a proper parser (HTML::TokeParser::Simple is my personal favourite) should make this a pretty straightforward job. For example, assuming a hash (%alt_text) with the relevant 'src' attribute as the key and the text as the value (as davido suggested), something like this would be what you're looking for:
use HTML::TokeParser::Simple; my $p = HTML::TokeParser::Simple->new( $filename ); while ( my $token = $p->get_token ) { if ( $token->is_tag('img') && !defined $token->get_attr('alt') ) { $token->set_attr('alt', $alt_text{ $token->get_attr('src') } ); } print $token->as_is; }