# Sub the tags back in. $str =~ s|<(\d+)>|<$tags[$1]>|gs ;