in reply to Need explanation: what \$_ and ${} do

${} is a syntactic construct that dereferences a scalar reference. Its inside can be any arbitrarily complex expression. \ is used to make references, so \$_ returns a reference to $_. See perlreftut.

So in your code, $1 is assigned to $_ (because $1 cannot be modified but $_ can), then s|\s*\=\s*|=|gsi removes the spaces around any equals signs in $_, and finally a reference to $_ is returned which immediately gets dereferenced to insert its value.

This is quite obfuscated, particularly due to the massively annoying choice of | as the regex delimiter. I wonder why the original programmer used /e at all. Doing something like ${ $var = do_something(), \$var } is a common trick to embed code in contexts where it would not otherwise be possible – f.ex., you can use this to put short snippets of code into heredocs. But with /e, this is completely unnecessary, you can simply write the above code like so:

$x =~ s{ < ([^>]*) > }{ $_ = $1; s{ \s* \= \s* }{=}gsix; "<$_>" }gisex +;

Note that I threw in an /x in both cases, so that I could use whitespace to make the patterns more readable. See perlretut (particularly, Building a regexep).

Makeshifts last the longest.