sub fix_umlaut { my ( $tagname, $attr, $text ) = @_; $output .= $text; if ( $tagname eq 'idx:orth' && $attr->{value} =~ s/([$um])/$replace{$1}/g ) { $output .= qq{}; # repeat the tag with modified umlauts } }