Hello Brother,

Perhaps you can help me. I'm trying to format a book for display on an e-Reader. The original is html. In the original there are footnotes in the text. The footnote number in the main body points to the footnote text through a hyperlink. The text of the footnote is in a different file.

What I'd like to do is this:

  1. Search all the files for the first footnote text and store the match as a variable.
  2. Then delete the footnote text.
  3. Search all the files for the corresponding footnote number in the main body and insert the footnote text there as part of the main body.
  4. Then repeat the action for all the footnotes throughout every file in the directory.

To give an example:

The main body text looks like this:

some words<a href="different_file.html#note1">1</a>

The footnote text looks like this:

<a id="note1">Here is the footnote text.</a>

I can write a regular expression to pull out the footnote text from the above string. And I can write another regexp to insert that text in the appropriate place in the main body. But I don't know Perl. There are hundreds of footnotes and it would be great to automate the process.

The reason I want the footnote text in the main body is because I'm using Latex to create the book, and that's the best way to reference footnotes in that program.

I hope this makes sense. If there's a convenient way to do this, I'd appreciate any help.

Thanks! best wishes, Ryan


In reply to multiple search/replace across multiple files by ryan(ma)

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.