perl - Strawberry Perl 无法识别 OSNAME 的特殊变量

标签 perl ansi strawberry-perl

我最近在运行 Windows 7 的 PC 上将 Strawberry Perl 从版本 5.14.1.1-32bit 升级到 5.24.0-64bit。我有一个在 Windows 和 Linux 下运行的 perl 脚本,当我使用旧版本时,命令

use if $^O eq 'MSWin32' , 'Win32::Console::ANSI';

工作,但现在我已经升级,我收到错误消息
Unrecognized character \x0F; marked by <-- HERE after use if $<-- HERE near column9 at p:\bin\abc.pl line 31.

有谁知道发生了什么变化,以及如何让新版本的 Strawberry Perl 接受命令?在此先感谢所有回复的人。

最佳答案

您的代码包含 Shift In控制字符 (0x0F),也称为“Control-O”,而不是字符 ^O .这适用于旧版本的 Perl,但为 deprecated in version 5.20.0 :

Literal control characters in variable names

This deprecation affects things like $\cT, where \cT is a literal control (such as a NAK or NEGATIVE ACKNOWLEDGE character) in the source code. Surprisingly, it appears that originally this was intended as the canonical way of accessing variables like $^T, with the caret form only being added as an alternative.

The literal control form is being deprecated for two main reasons. It has what are likely unfixable bugs, such as $\cI not working as an alias for $^I, and their usage not being portable to non-ASCII platforms: While $^T will work everywhere, \cT is whitespace in EBCDIC. [perl #119123]


As of 5.24.0 , 使用包含非图形 ASCII 控制字符的变量名称会导致语法错误。

关于perl - Strawberry Perl 无法识别 OSNAME 的特殊变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37792582/

相关文章:

linux - 开发一个程序来分析 Linux 磁盘的目录结构并识别任何大于 500kbytes 的文件

perl - Tie::IxHash 在哈希的哈希中排序关联数组?

cucumber - ANSICON 在 Windows 7 Enterprise 64 位上运行的问题

c - 为什么我的数组没有正确存储结构?

perl - 同时使用 ActivePerl 和 Strawberry

linux - 使用 Perl 检查目录是否存在

perl - 这可以在一行中完成吗?

utf-8 - VBS Scripting.FileSystemObject 需要帮助编写 ANSI txt 文件

perl - 如何使用 Strawberry Perl 将 Perl 脚本编译为 Windows 可执行文件?

perl - (Windows 10)尝试安装 PPM 和 CPAN 都失败的 Perl 模块?