punch_card_don has asked for the wisdom of the Perl Monks concerning the following question:

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.

Replies are listed 'Best First'.
Re: Correct line-feed characters to output to get MS Office to break new line?
by punch_card_don (Curate) on Feb 18, 2006 at 15:53 UTC
    Found it.

    The text string was being passed via an html form, which the MS Office document's vba then read in. I was passing the string in a <input type="text"> form element, which was of course squashing out the line feeds.

    Replacing that with a <textarea> form element that is meant to preserve line feeds solved the problem.

    Had nothing to do with getting Perl to correctly output carriage returns for Windows.




    Forget that fear of gravity,
    Get a little savagery in your life.
Re: Correct line-feed characters to output to get MS Office to break new line?
by Anonymous Monk on Feb 18, 2006 at 15:45 UTC
    perldoc -f binmode