4

I recently upgraded Strawberry Perl from version 5.14.1.1-32bit to 5.24.0-64bit on my PC running Windows 7. I have a perl script I run under both Windows and Linux, and when I was using the old version the command

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

worked, but now that I've upgraded I get the error message

Unrecognized character \x0F; marked by <-- HERE after use if $<-- HERE near column9 at p:\bin\abc.pl line 31.

Does anyone know what changed, and how I can get the new version of Strawberry Perl to accept the command? Thanks in advance to all who respond.

Leslie
  • 618
  • 4
  • 14

1 Answers1

7

Your code contains the Shift In control character (0x0F), also known as "Control-O", instead of the characters ^ and O. This works in older versions of Perl but was 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, using a variable name containing non-graphical ASCII control characters results in a syntax error.

Community
  • 1
  • 1
ThisSuitIsBlackNot
  • 23,492
  • 9
  • 63
  • 110
  • 1
    I changed it as you suggested, and it worked like a charm. Thanks! – Leslie Jun 13 '16 at 15:29
  • I think the talk about `"\cO"` being ASCII `SI` and the link to Wikipedia is irrelevant noise. On the other hand, the link to perldelta 5.24 is central and should be at the top – Borodin Jun 13 '16 at 16:44
  • I for one am *not* surprised that the original intent was for it to be an actual control character. That was the sort of thing that was cool about perl in the beginning - its lack of unnecessary limitations. Control characters in a variable name? Why not! (Having to care about EBCDIC has never been and will never be cool) –  Jun 13 '16 at 18:14