in reply to using $1 as find string

What you're looking for is called a backreference (see perlre). In the pattern you'll want to use\1 (or \2 or \3...) instead of $1 (or $2 ...). On the RHS keep using $1.

while (<DATA>){ s!</it><(.*?)><it>(.*?)</it></\1>!<$1>$2</$1></it>!g; # ^ here's the difference print; } __DATA__ <it>a</it>+2<it>b</it><inf><it>cd</it></inf> <it>a</it>+2<it>b</it><sup><it>cd</it></sup>
output: <it>a</it>+2<it>b<inf>cd</inf></it> <it>a</it>+2<it>b<sup>cd</sup></it>

Update: fixed pointer to \