Macho Monks,

My Perl script is outputting a text string to an MS Office app running on the user's PC, almost always under Windows. The document opens just fine, but I cannot get line breaks where I want them.

I've tried:

$part_1 = "foo"; $part_2 = "bar" print $part_1."\n".$part_2; print $part_1."\r".$part_2; print $part_1."\n\n".p$art_2; print $part_1."\r\n".$part_2; print $part_1."\r\r".$part_2;
If I pass $part_1 and $part_2 to Ms Office through an html form and use VBA within the file to assemble the lines using
Text = part_1 + Chr$(CharCode:=13) + part_2
it works just fine, I get the line break I want. So I tried in PErl
$cr = 13; print $part_1.chr($cr).$part_2;
but still no luck.

What's the trick to insert a Windows line break into an output text stream?

Thanks.




Forget that fear of gravity,
Get a little savagery in your life.

In reply to Correct line-feed characters to output to get MS Office to break new line? by punch_card_don

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.