Yenya's World

Fri, 30 Jan 2009

"Too late for -CS" Howto

Speaking on portability: I have recently came across a problem with the newest Perl. We start most of our scripts with the -CS or -CSD switch on the shebang line. Since perl-5.10, this no longer works, it fails with Too late for "-CS" option error message. While I don't understand what has led the Perl developers to this incompatible change, here is the workaround:

The -CS switch can be substituted with the following code at the beginning of the script:

use open ':std', ':utf8';
use open IO => ':bytes';

and the -CSD switch can be replaced with just

use open ':std', ':utf8';

Morale of the story: the most portable languages (and language features) are those which are sufficiently old (which Unicode support in Perl or the STL library in C++ is not). Apart from this problem Perl still seems to be a relatively portable language even for large projects such as IS MU.

Section: /computers (RSS feed) | Permanent link | 3 writebacks

3 replies for this story:

adelton wrote:

$ perl -CS -e 'use utf8; print "křížala\n";' křížala $ perl -v This is perl, v5.10.0 built for x86_64-linux-thread-multi Copyright 1987-2007, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. What am I missing?

adelton wrote:

Hmm. The above thing really had newlines in the textarea. Couldn't you retain them?

Yenya wrote: Re: adelton

Sorry about the newlines, I will try to be more liberal about what I allow in comments. The -CS does not work on the shebang line inside the script, but it works on the real command line. See perldiag(1).

Reply to this story:

 
Name:
URL/Email: [http://... or mailto:you@wherever] (optional)
Title: (optional)
Comments:
Key image: key image (valid for an hour only)
Key value: (to verify you are not a bot)

About:

Yenya's World: Linux and beyond - Yenya's blog.

Links:

RSS feed

Jan "Yenya" Kasprzak

The main page of this blog

Categories:

Archive:

Blog roll:

alphabetically :-)