我使用Perl6 :: Form來生成表格並將其輸出到文本文件。無論我做什麼,看起來,我都無法輸出Windows行尾。我試過local $OUTPUT_RECORD_SEPARATOR = "\r\n";
我試過把\r\n
添加到我的格式字符串中。沒有骰子。在Perl6中使用Windows行結尾::表格
我的代碼:
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;
['use English'](http://search.cpan.org/~dom/perl-5.12.5/pod/perlvar.pod#Predefined_Names)?否則,你只能通過'$ \\'來訪問輸出分隔符。 – mob 2013-02-08 22:04:30
另外,變量名是'$ OUTPUT_RECORD_SEPARATOR'。 – mob 2013-02-08 22:08:35
@mob是的,我正在使用'English'和'$ OUTPUT_RECORD_SEPARATOR'。將改正帖子。 – 2013-02-08 22:44:32