in reply to Hash Arrays

You're on the right track with the first half. The second half is confusing. You're looping through the attributes and trying to read from the file multiple times (which doesn't work -- you can't stand twice in the same stream). You're trying to execute what appears to be a vi command outside of vi.

Try this instead. We'll build up a regex and process each line one by one:

my $regex = qr( '(' . join('|', map { quotemeta( $_ ) } keys %attributes_hash ) . ')' ); while (<H>) { s/$regex/$attributes_hash{ $1 }/g; print; }

That prints the output, so you'll either have to redirect it to another file internally or externally. It also doesn't handle the case of some attributes being longer than others, or being substrings of others. Throwing a sort before the map will help with that.

Of course, if you're processing HTML files with regular expressions, the odds of false positives are not in your favor. Learning to use a module such as HTML::Parser or HTML::TokeParser would really pay off.