in reply to Global replace issue
foreach my $key (keys %subs) { warn "checking key: $key\n"; if ($html =~ s/$key/$subs{$key}->()/eg) { warn $html; last; } } [download]
So that you leave the loop once you've made a substitution.