Forgive my ignorance as I am a complete newbie to Perl. And my desired task I'm afraid takes theskills of a master. So I humbly present my problem here in hopes that one of the many masters will help a new initiate. Thanks in advance.

I need to loop through a large html file, find usage of umlauted characters in a specific tag, copy and alter the tag by substituting a unicode character with two new characters, and append that tag next to the original tag. I feel like I can use Perlre to find the pattern, and then the tag will have to be copied, altered, and placed correctly next to the new tag.

1. The script must copy a tag and replace the umlauted letter with a oe,ue, or ae and append this to the same location below is two examples.

<idx:orth value="aufhören"/> <idx:orth value="Förderverein"/>

What we need is two tags like this:

<idx:orth value="aufhören"/><idx:orth value="aufhoeren"/>

or

<idx:orth value="Förderverein"/><idx:orth value="Foerderverein"/>

2. The case of the headword should be retained. If it is capitalized then the new tag should also be capitalized. An example is presented above and below.

<idx:orth value="Öl"/><idx:orth value="Oel">

The script will have to identify every use of an umlaut in this tag set, copy the tag, and write it next to the original tag with the spelling change.

Below is an example of the full entry:

<idx:entry name="dic" scriptable="yes" wild="yes" spell="yes"><idx:sho +rt><div height="4"><a name="51707"/><div><idx:orth value="Förderverein"/><b>F</b><font color +="#000000"><betonung/><b><b>ö</b></b></font><b>r</b>·<b>der</b>·<b>ve +r</b>·<b>ein, </b>der: </div><blockquote>zur <a href="#51698"><font s +ize="+1"><b><img hspace="0" align="middle" hisrc="bbm/t2i-ie/U8593.1NI48A-h.gif"/></b></font> Förderung (1)</a> e +iner bestimmten Sache gegründeter Verein.</blockquote></div></idx:sho +rt></idx:entry><div height="10" align="center"><img hspace="0" vspace +="0" align="middle" losrc="bbm/rectangle-php/150-1-U35555555-l.gif" h +isrc="bbm/rectangle-php/520-4-U35555555-h.gif" src="bbm/rectangle-php +/200-1-U35555555-m.gif"/><br/></div>

A corrected version of the html would look like this:

<idx:entry name="dic" scriptable="yes" wild="yes" spell="yes"><idx:sho +rt><div height="4"><a name="51707"/><div><idx:orth value="Förderverei +n"/><idx:orth value="Foerderverein"/><b>F</b><font color="#000000"><b +etonung/><b><b>ö</b></b></font><b>r</b>·<b>der</b>·<b>ver</b>·<b>ein, + </b>der: </div><blockquote>zur <a href="#51698"><font size="+1"><b>< +img hspace="0" align="middle" hisrc="bbm/t2i-ie/U8593.1NI48A-h.gif"/></b></font> Förderung (1)</a> e +iner bestimmten Sache gegründeter Verein.</blockquote></div></idx:sho +rt></idx:entry><div height="10" align="center"><img hspace="0" vspace +="0" align="middle" losrc="bbm/rectangle-php/150-1-U35555555-l.gif" h +isrc="bbm/rectangle-php/520-4-U35555555-h.gif" src="bbm/rectangle-php +/200-1-U35555555-m.gif"/><br/></div>

In reply to Copy html tag and replace umlauts with alternate spellings by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.