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