Your problem has a simple solution, though you should still check out templating mechanisms.

Instead of   template =~ s/TEXTGOESHERE/$textfile/se try   $template =~ s/TEXTGOESHERE/$textfile/g; The /s modifier that you're using says to that a . in a regular expression should match a newline. Since you don't have a . in your regular expression, this is a no-op.

The /e modifier says to treat the replacement string as a Perl expression, and to use that value of that expression when making the replacement. This is almost certainly not what you intend.

By using /g instead, you're saying to replace every occurance of TEXTGOESHERE with the contents of $textfile. If you have only one TEXTGOESHERE, you'll only get one substitution.

Try it.


In reply to Re: perl fool - inserting text into html doc by dws
in thread perl fool - inserting text into html doc by cameltrader

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.