Monday, 15 April 2013

unicode - How to exit a Perl program as soon as the "Wide character in print at X line Y" message appears? -



unicode - How to exit a Perl program as soon as the "Wide character in print at X line Y" message appears? -

i have perl programme that's giving me next output:

wide character in print @ foo.pl line 139, <file> line 1. wide character in print @ foo.pl line 139, <file> line 2. wide character in print @ foo.pl line 139, <file> line 3.

as don't want add together :utf8 layer, , don't want turn off warnings either, i'm looking way terminate programme , exit error code if message above appears.

as print statement 1 throwing error, tried utilize or die next print statement, didn't help. e.g.>

print output $_."\n" or die "something wrong happened - $!";

i guess that's not working because print not failing - it's displaying message.

what looking is:

use warnings fatal => 'utf8';

which cause "wide character" warning fatal, , cause perl process die.

for example:

#!/usr/bin/env perl utilize strict; utilize warnings; utilize utf8; utilize feature 'say'; (1 .. 3) { "παν γράμμα"; } "=" x 80; utilize warnings fatal => 'utf8'; (1 .. 3) { "παν γράμμα"; }

outputs:

alex@kyon:~$ ./fatal_wide.pl wide character in @ ./fatal_wide.pl line 9. παν γράμμα wide character in @ ./fatal_wide.pl line 9. παν γράμμα wide character in @ ./fatal_wide.pl line 9. παν γράμμα ================================================================================ wide character in @ ./fatal_wide.pl line 17.

and exits non-zero exit status:

alex@kyon:~$ echo $? 255

perl unicode

No comments:

Post a Comment