关于编译时错误的问题

sid*_*com 2 perl compilation

#!/usr/bin/env perl
use warnings;
use 5.012;

say "no semicolon"

say "World";
say "World";
say "World";
say "World";
say "World";

# syntax error at ./perl1.pl line 7, near "say"
# Execution of ./perl1.pl aborted due to compilation errors.
Run Code Online (Sandbox Code Playgroud)

.

#!/usr/bin/env perl
use warnings;
use 5.012;

my $character = "\x{ffff}";

say "Hello";
say "Hello";
say "Hello";
say "Hello";
say "Hello";

# Unicode non-character 0xffff is illegal for interchange at ./perl1.pl line 5.
# Hello
# Hello
# Hello
# Hello
# Hello
Run Code Online (Sandbox Code Playgroud)

为什么第二个脚本没有告诉我,有编译时错误?

当我不能 - 用"使用警告FATAL => qw(全部);" - 使用Try :: Tiny或block-eval捕获错误,我可以得出结论,这是一个编译时错误吗?

#!/usr/bin/env perl
use warnings FATAL => qw(all);
use 5.012;
use Try::Tiny;

my $character;

try {
    $character = "\x{ffff}";
} catch {
    die "---------- caught error ----------\n";
};

say "something";

# Unicode non-character 0xffff is illegal for interchange at ./perl1.pl line 9.
Run Code Online (Sandbox Code Playgroud)

soc*_*pet 7

Unicode non-character 0xffff is illegal for interchange at ... 是编译时警告.

当你use warnings FATAL => all,你要求Perl将所有警告视为错误,因此它成为编译时错误.