Rafael Garcia-Suarez wrote:
> 2008/11/11 karl williamson <public@khwilliamson.com>:
>> But there are problems with pragmas. As I've discovered, the charnames
>> pragma goes away in an eval. That this should happen was not obvious to me,
>> and I suspect not so to the average Perl progammer. It doesn't DWIM, and
>> I'm not convinced it is the right thing to do. It means that complementing
>> the default from release to release can cause programs to have to add pragma
>> calls to their evals.
>
> To me it's a bug. Actually that might be caused by charnames storing
> an arrayref in %^H. But I don't reproduce it with 5.10 (the script
> below works). Do you have some test code ?
>
> use strict;
> use warnings;
> use 5.01;
> use charnames 'greek';
> say "\N{sigma} is Greek sigma";
> eval { say "\N{sigma} is Greek sigma"; };
> eval ' say "\N{sigma} is Greek sigma"; ';
>
>
I can't get it to fail now either, except in what prompted my original
statement:
use charnames ':full';
use Test::More tests => 2;
like('A', '/\N{U+0041}/');
like('A', '/\N{LATIN CAPITAL LETTER A}/');
The first succeeds and the second fails. The response was I should be
using qr// instead of single quotes. But it is odd that one works and
one fails.
Earlier, before I converted to using Test, I was doing an eval myself
and getting a failure message that came from these lines in regcomp.c:
vFAIL2("Constant(\\N{%s}) unknown: "
"(possibly a missing \"use charnames ...\")",
when in fact I did have the appropriate "use charnames" in my program.
That is why I surmised the problem was an eval.
I also know that in 5.8, I had to put the appropriate "use" statement
inside my evals to get \K in re's (it was in a cpan module at the time)
to work.
So I don't know. I guess there are other factors involved.
But, for my pragma enabling the latin1 semantics behavior, I was
planning to use a bit in $^H, just like "use bytes" does. The
documentation says an eval gets a copy of this scalar, pushed at its
beginning. It says the same about %^H. Your comment above leads me to
think this isn't how it works.
Thread Previous
|
Thread Next