我在Windows 7上安装了Strawberry Perl 5.22,然后在Padre / Dwimperl(包括草莓5.14)上安装了它。然后我卸载了5.22。然后我使用“D:\ Dwimperl \ perl \ bin”中的“cpan SDL”安装了SDL。它似乎安装正确。
使用Padre(和/或命令行)我可以运行Perl脚本。但是,如果我引入了一个错误(“$ r = 0;”),那么我将看不到来自warnings / strict / diagnostics的正常输出,除非我注释掉“use utf8;”
用“use utf8;”我得到了这个无用的错误:
BEGIN not safe after errors--compilation aborted at D:/Dwimperl/perl/lib/diagnos
tics.pm line 599.
没有它我会得到更有帮助的错误:
Global symbol "$r" requires explicit package name at sdl2.pl line 12.
Execution of sdl2.pl aborted due to compilation errors (#1)
(F) You've said "use strict" or "use strict vars", which indicates
that all variables must either be lexically scoped (using "my" or "state"),
declared beforehand using "our", or explicitly qualified to say
which package the global variable is in (using "::").
Uncaught exception from user code:
Global symbol "$r" requires explicit package name at sdl2.pl line 12.
Execution of sdl2.pl aborted due to compilation errors.
at sdl2.pl line 15
这是我正在使用的脚本:
#! D:\Dwimperl\perl\bin\perl.exe
use warnings;
use strict;
use diagnostics;
use utf8;
binmode STDOUT, ':utf8';
$r = 0;
print "Hello World!\n";
exit 0;
有人可以建议我如何保留有用的错误并使用utf8吗?