【问题标题】:Text::LineFold: Setting "ColMax"Text::LineFold: 设置“ColMax”
【发布时间】:2013-05-11 08:33:25
【问题描述】:

看起来设置“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 ...

【问题讨论】:

    标签: perl unicode printing


    【解决方案1】:

    我的脚本中有一个错误。现在可以了:

    #!/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} );
    } 
    

    【讨论】:

      猜你喜欢
      • 2015-04-04
      • 2014-05-16
      • 1970-01-01
      • 1970-01-01
      • 2014-07-27
      • 2019-05-06
      • 1970-01-01
      • 2020-01-12
      • 1970-01-01
      相关资源
      最近更新 更多