develooper Front page | perl.perl5.porters | Postings from February 2000

C<use utf8> should never set $^U

Thread Previous | Thread Next
From:
Chip Salzenberg
Date:
February 4, 2000 00:54
Subject:
C<use utf8> should never set $^U
Message ID:
20000204005411.A7521@perlsupport.com
Having finally gotten around to reading perllocale, I find this
welcome feature:
    [...] if the C<$^U> global flag is set to C<1>, nearly all
    operations will use character semantics by default.

But I also find this *unwelcome* feature:
    As an added convenience, if the C<utf8> pragma is used in the
    C<main> package, C<$^U> is enabled automatically.

I consider this behavior less a convenience and more a bug.  I think
it's a bad idea to give one pragma both lexical effects and global
effects.  Please separate them.

Consider: In a main program (which could be quite large, after all),
there could easily be a need to C<use utf8> in an inner block just for
some small purpose, e.g. turning on a Unicode RE feature.  Yet if I
read the docs correctly, that single pragma use changes the behavior
of the whole program!  And the only way around that weirdness --
assuming you notice it in time -- is to temporarily change the current
package in that inner block.  Yuck.

    [XXX: Should there be a -C switch to enable $^U?]

Absolutely.  And then the intent of the global behavior of C<use utf8>
can be met by putting "-C" on the shebang line.
-- 
Chip Salzenberg          - a.k.a. -           <chip@valinux.com>
        "He's Mr. Big of 'Big And Tall' fame."  // MST3K

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About