我正在使用 Perl6::Form 生成表格并将其输出到文本文件。无论我做什么,似乎都无法输出 Windows 行尾。我试过local $OUTPUT_RECORD_SEPARATOR = "\r\n";
我试过附加\r\n
到我的格式字符串。没有骰子。
我的代码:
use English;
local $OUTPUT_RECORD_SEPARATOR = qq{\r\n};
my @column_headings = @{ shift $args->{'data'} };
my @rows = @{ $args->{'data'} };
my $header_format = join q{|}, (q/{]]]][[[[}/) x scalar @column_headings;
my $field_format = join q{|}, (q/{]]]]]]]]}/) x scalar @column_headings;
# formatting starts with headers followed by double line
my @format_data = ( $header_format, @column_headings, );
push @format_data, join q{|}, (q/==========/) x scalar @column_headings;
foreach my $row (@rows) {
push @format_data, ( $field_format, @{$row} );
}
my $text = form @format_data;
my ( $fh, $tempfile ) = File::Temp::tempfile;
$fh->print($text) or croak(qq/Failed to write to tempfile: $OS_ERROR/);
close $fh;