1

看起来设置“ColMax”有效,但它发出两个警告。难道我做错了什么?

#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use open qw(:std :utf8);
use Term::ReadKey;
use Text::LineFold;
use Term::Choose qw(choose);

my %text = (
    a => 'aaaaaaaaaa ' x 100,
    b => 'bbbbbbbbbb ' x 100,
    c => 'cccccccccc ' x 100,
);

my $line_fold = Text::LineFold->new(
    Charset       => 'utf-8',
    OutputCharset => '_UNICODE_',
    Urgent        => 'FORCE',
);

while ( 1 ) {
    my $choice = choose( [ undef, 'a', 'b', 'c' ], { undef => 'Exit' } );
    last if ! defined $choice;
    $line_fold->config( 'ColMax', GetTerminalSize );
    print $line_fold->fold( '' , '', $text{$choice} );
}

_config: Setting unknown option 35 at [...]/Unicode/LineBreak.pm line 217.
_config: Setting unknown option 0 at [...]/Unicode/LineBreak.pm line 217.
# normal output ...
4

1 回答 1

0

我的脚本中有一个错误。现在它起作用了:

#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use open qw(:std :utf8);
use Term::ReadKey;
use Text::LineFold;
use Term::Choose qw(choose);

my %text = (
    a => 'aaaaaaaaaa ' x 100,
    b => 'bbbbbbbbbb ' x 100,
    c => 'cccccccccc ' x 100,
);

my $line_fold = Text::LineFold->new(
    Charset       => 'utf-8',
    OutputCharset => '_UNICODE_',
    Urgent        => 'FORCE',
);

while ( 1 ) {
    my $choice = choose( [ undef, 'a', 'b', 'c' ], { undef => 'Exit' } );
    last if ! defined $choice;
    $line_fold->config( 'ColMax', ( GetTerminalSize )[0] );
    print $line_fold->fold( '' , '', $text{$choice} );
} 
于 2013-05-12T05:14:55.867 回答