perl - Using Windows line endings in Perl6::Form -
i'm using perl6::form generate table , output text file. no matter do, seems, can't output windows line endings. i've tried local $output_record_separator = "\r\n";
i've tried appending \r\n
format strings. no dice.
my code:
use english; local $output_record_separator = qq{\r\n}; @column_headings = @{ shift $args->{'data'} }; @rows = @{ $args->{'data'} }; $header_format = bring together q{|}, (q/{]]]][[[[}/) x scalar @column_headings; $field_format = bring together q{|}, (q/{]]]]]]]]}/) x scalar @column_headings; # formatting starts headers followed double line @format_data = ( $header_format, @column_headings, ); force @format_data, bring together q{|}, (q/==========/) x scalar @column_headings; foreach $row (@rows) { force @format_data, ( $field_format, @{$row} ); } $text = form @format_data; ( $fh, $tempfile ) = file::temp::tempfile; $fh->print($text) or croak(qq/failed write tempfile: $os_error/); close $fh;
according docs,
the file returned file::temp have been opened in binary mode if such mode available. if not correct, utilize c function alter mode of filehandle.
as such, re-add :crlf nowadays on file handles opened in windows using next after open before print.
$fh->binmode(':crlf');
windows perl line-endings
No comments:
Post a Comment