我已经在Windows 7上安装了Strawberry Perl 5.22,然后安装了包括Strawberry 5.14的Padre/Dwimperl。然后我卸载了5.22,并使用"D:\Dwimperl\perl\bin"中的"cpan SDL"安装了SDL。看起来它安装正确。
使用Padre(和/或命令行),我可以运行Perl脚本。但是,如果我引入一个错误("$r=0;"),则除非我注释掉"use utf8;",否则我将不会看到来自警告/严格/诊断的正常输出。
使用"use utf8;",我得到这个无用的错误:
没有它,我会得到更有帮助的错误提示:
使用Padre(和/或命令行),我可以运行Perl脚本。但是,如果我引入一个错误("$r=0;"),则除非我注释掉"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?
use diagnostics
。它实际上只是获取use warnings
的输出并在 perldiag 中查找以打印出来,如果大多数编辑器和IDE实际上没有查找warnings
模块的输出来突出显示问题,那将是很好的。 - tjd