in reply to Slow regexp

Using symbolic references, the code you've written can be reduced as follows and this will also work faster.

@tags = qw[body title h1 h2 h3 h4 h5 h6 li p a]; @attributes = qw[alt href]; foreach $tag (@tags) { $$tag++ while ($html =~ /<$tag.*?>.*?\b$WHATWANT{'term'}'?s?\b.*?< +\/$tag>/gis); } foreach $attribute (@attributes) { $$attribute++ while ($html =~ /(alt|href)=["'].*?\b$WHATWANT{'term +'}'?s?\b.*?["']/gis); }
Mani.