在字符串中使用未初始化的值$ _ - mojolicious perl

时间:2017-07-21 09:34:05

标签: perl mojolicious

    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.
    Use of uninitialized value $_ in string at /usr/local/share/perl/5.20.2/Mojo/Collection.pm line 45.

这在mojolicious的背景下意味着什么?我假设在呈现html页面时存在某种格式不正确的字符串。非常感谢任何帮助。

sub join { Mojo::ByteStream->new(join $_[1] // '', map {"$_"} @{$_[0]}); }

这是mojolicious源代码中的一行,但我相信它会被我的html文件中的某些内容触发,我将免去你看到的痛苦。

1 个答案:

答案 0 :(得分:-1)

  1. 您不需要使用' map'。 join将采用数组。
  2. 很明显你的子书写的是这样的:

    sub join {
        my $list = shift;
        my $sep  = shift // '';
        Mojo::ByteStream->new( join( $sep, @$list ) );
    }
    
  3. 转储所有变量,查看其中的内容。

  4. 万一你从未使用过Data :: Dumper,请执行以下操作:

    use Data::Dumper;
    print Dumper($list);
    
  5. BTW,Mojolicious中包含dumper方法。 $c->dumper( $your_var )