in reply to Speeding up a Perl code. Can it be faster?

It'd be helpful to know more of the specifics. For example, if the keys are limited to alphanumeric labels, the simplification could provide further speedup. Anyway, here's one regex-convoluted aka "adding problems to problems" version for your perusal:

sub uhuu { my $keys = join "|", map "\Q$_\E", ($match_list =~ m{([^/,]+)/[^,] +*}g); my %R; return unless $attrs =~ m{ \A \Q$tag\E \s+ (?: ($keys)=(\S+) (?(?{ defined $R{$1} || ($R{$1}=$2, 0) })(?! +)) \s* )*+ \z }x; $markup =~ s[X{($keys)}][ $R{$1} // $& ]ger }

A side-note to benchmarkers: localize the globals that you modify. ("On the importance of testing your testing.")