Dar*_*all 5 sorting perl timezone
use DateTime::TimeZone::Local;
use Test::More tests => 1;
my @input = (1 .. 10 );
my (@output) = sort {
DateTime::TimeZone::Local->TimeZone();
$a cmp $b
} @input;
is_deeply(\@output, \@input);
Run Code Online (Sandbox Code Playgroud)
输出:
1..1
Can't return outside a subroutine at /usr/local/share/perl/5.8.8/DateTime/TimeZone/Local.pm line 72.
# Looks like your test exited with 9 before it could output anything.
shell returned 9
Run Code Online (Sandbox Code Playgroud)
我已经检查过它肯定是在一个子程序中.它似乎与使用的模块无关,此代码也会导致相同的错误:
my @output = sort {
sub1();
} (1 .. 5);
sub sub1 {
eval "use ModuleDoesntExist";
return 1; # remove this and get a seg fault
}
Run Code Online (Sandbox Code Playgroud)
看起来这是PERL中的一个错误.有任何想法吗?更感兴趣的是为什么会发生这种情况而不是解决方法 - 只有在模块不存在时才会发生.