Yes, you can change Perl's built in variables such as $/ and $\ to suit your needs, but something tells me you would be better off solving your problem with a CPAN module instead - a solution that has been tried, tested, and proven to be to robust enough to take care of the problems you haven't addressed yet. For example, HTML::FromText does a pretty darned good job of converting plain text into HTML for you. But adding line break tags is really trivial:

$str =~ s/\r?\n?/<br\/>\n/g; $_ =~ s/\r?\n?$/<br\/>\n/ for @array;

Question ... did you mean a literal &lt;BR> or a <BR> tag? Either case, you really should be keeping up date with HTML standards ... lower case and close off non-nested tags: <br/>.

Please do heed dragonchild's advice and give us more information on what you are trying to do. For example, posting a good snippet of the file you are parsing would be a good start.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re: Special Characters by jeffa
in thread Special Characters by CronCamel

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.