Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: utf8 whacks Carp in 5.12.1

by Anonyrnous Monk (Hermit)
on Jan 25, 2011 at 05:22 UTC ( [id://884059]=note: print w/replies, xml ) Need Help??


in reply to utf8 whacks Carp in 5.12.1

I can reproduce it with 5.12.2, too.  Definitely a bug, I'd say.

FWIW, the same problem exists with

#!/usr/local/bin/perl5.12.2 use strict; use diagnostics; use utf8; $c;

As soon as "use utf8" is in the game, the output is

BEGIN not safe after errors--compilation aborted at /usr/local/lib/per +l5/5.12.2/diagnostics.pm line 569.

while if you comment it out, you get the expected "Global symbol "$c" requires explicit package name", followed by the corresponding diagnostic message.

The order of the use statements doesn't seem to matter, and use utf8 without use diagnostics doesn't produce the error.  The code works fine with 5.10.1.

Replies are listed 'Best First'.
Re^2: utf8 whacks Carp in 5.12.1
by andal (Hermit) on Jan 25, 2011 at 13:34 UTC

    Yep, the problem is with the matching done inside of diagnostics.pm at the reported line. If before this line one adds

    utf8::encode($_) if utf8::is_utf8($_);
    on line 552 of the diagnostics.pm then the problem goes away. Well, actually this problem goes away, instead the Carp.pm fails, again with regex matching.
    Global symbol "$c" requires explicit package name at test.pl line 8. Execution of test.pl aborted due to compilation errors (#1) (F) You've said "use strict" or "use strict vars", which indicates + that all variables must either be lexically scoped (using "my" or +"state"), declared beforehand using "our", or explicitly qualified to say which package the global variable is in (using "::"). BEGIN not safe after errors--compilation aborted at /usr/lib64/perl5/5 +.12.2/Carp.pm line 113.
    Really weird problem. Things work fine for substitute but fail for regular matching.

    Looks like this bug happens to be only in $SIG{__DIE__} handler. At least I could reproduce it in

    use strict; use utf8; BEGIN { $SIG{__DIE__} = \&report; sub report { my $arg = shift; $arg = "'$arg'" unless $arg =~ /^-?[\d.]+\z/; warn("Done\n"); } } $c;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://884059]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2024-04-23 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found