Most likely you can just transplant the code from here to there.

I tried that but I couldn't get it to work. binmode STDOUT; did work for my platform.

--- tpage 2011-07-12 04:27:14.140625000 -0700 +++ tpage-new2 2011-07-12 04:42:08.796875000 -0700 @@ -39,6 +39,7 @@ # unshift any perl5lib directories onto front of INC unshift(@INC, @{ $config->perl5lib }); +my $binmode = $config->binmode; # get all template_* options from the config and fold keys to UPPER C +ASE my %ttopts = $config->varlist('^template_', 1); my $ttmodule = delete($ttopts{ module }); @@ -67,10 +68,13 @@ my $template = $ttmodule->new($ucttopts) || die $ttmodule->error(); +binmode STDOUT; # process each input file foreach my $file (@ARGV) { $file = \*STDIN if $file eq '-'; - $template->process($file) +#~ $template->process($file, undef, \*STDOUT, $binmode ? {binmode + => $binmode} : {} ) +#~ $template->process($file, undef, \*STDOUT, {binmode => !!$binm +ode} ) + $template->process($file, undef, \*STDOUT, ) || die $template->error(); } @@ -83,6 +87,8 @@ ERROR => sub { die(@_, "\ntry `$NAME --help'\n") } }, 'help|h' => { ACTION => \&help }, + 'binmode=s', + 'template_encoding|encoding=s', 'template_absolute|absolute' => { DEFAULT => 1 }, 'template_relative|relative' => { DEFAULT => 1 }, 'template_module|module=s', @@ -167,6 +173,10 @@ --perl5lib=DIR Specify additional Perl library directori +es --template_module=MODULE Specify alternate Template module +File encoding options + --binmode=value Set binary mode of output files + --encoding=value Set encoding of input files + See 'perldoc tpage' for further information. END_OF_HELP

I also found Template::Parser::LocalizeNewlines which also works

--- tpage 2011-07-12 04:27:14.140625000 -0700 +++ tpage-new 2011-07-12 04:38:37.093750000 -0700 @@ -26,6 +26,7 @@ use strict; use Template; use AppConfig; +use Template::Parser::LocalizeNewlines; my $NAME = "tpage"; my $VERSION = 2.70; @@ -61,6 +62,8 @@ # add current directory to INCLUDE_PATH unshift(@{ $ucttopts->{ INCLUDE_PATH } }, '.'); +$ucttopts->{ PARSER } = Template::Parser::LocalizeNewlines->new ; + # read from STDIN if no files specified push(@ARGV, '-') unless @ARGV;

In reply to Re^2: Template-Toolkit (tt2) tpage newline confusion by Anonymous Monk
in thread Template-Toolkit (tt2) tpage newline confusion by Anonymous Monk

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.