in reply to Getting Error in character class - Regex

You have to specify the end of the hashref
$input =~ s/<${imlre{$_}->[1]}[^>]*>//g
as there is ambiguity for brackets in the regex.