gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 19:48:37 27 4
gpt4 key购买 nike

我最近在运行 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com