Did you consider using HTML::Parser? it will parse the HTML (no need to use regexen to match the tags) and the attributes are presented to you in a nice hash, which solves your permutation "problem".
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
Comment on Re: Operator for "these expressions, in any order"