← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/locale.pm
StatementsExecuted 12 statements in 162µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs28µslocale::::BEGIN@4locale::BEGIN@4
11112µs50µslocale::::importlocale::import
0000s0slocale::::unimportlocale::unimport
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package locale;
2
31500nsour $VERSION = '1.02';
42148µs240µs
# spent 28µs (16+12) within locale::BEGIN@4 which was called: # once (16µs+12µs) by Pod::Spell::BEGIN@17 at line 4
use Config;
# spent 28µs making 1 call to locale::BEGIN@4 # spent 12µs making 1 call to Config::import
5
61600ns$Carp::Internal{ (__PACKAGE__) } = 1;
7
8=head1 NAME
9
10locale - Perl pragma to use or avoid POSIX locales for built-in operations
11
12=head1 SYNOPSIS
13
14 @x = sort @y; # Unicode sorting order
15 {
16 use locale;
17 @x = sort @y; # Locale-defined sorting order
18 }
19 @x = sort @y; # Unicode sorting order again
20
21=head1 DESCRIPTION
22
23This pragma tells the compiler to enable (or disable) the use of POSIX
24locales for built-in operations (for example, LC_CTYPE for regular
25expressions, LC_COLLATE for string comparison, and LC_NUMERIC for number
26formatting). Each "use locale" or "no locale"
27affects statements to the end of the enclosing BLOCK.
28
29Starting in Perl 5.16, a hybrid mode for this pragma is available,
30
31 use locale ':not_characters';
32
33which enables only the portions of locales that don't affect the character
34set (that is, all except LC_COLLATE and LC_CTYPE). This is useful when mixing
35Unicode and locales, including UTF-8 locales.
36
37 use locale ':not_characters';
38 use open ":locale"; # Convert I/O to/from Unicode
39 use POSIX qw(locale_h); # Import the LC_ALL constant
40 setlocale(LC_ALL, ""); # Required for the next statement
41 # to take effect
42 printf "%.2f\n", 12345.67' # Locale-defined formatting
43 @x = sort @y; # Unicode-defined sorting order.
44 # (Note that you will get better
45 # results using Unicode::Collate.)
46
47See L<perllocale> for more detailed information on how Perl supports
48locales.
49
50=head1 NOTE
51
52If your system does not support locales, then loading this module will
53cause the program to die with a message:
54
55 "Your vendor does not support locales, you cannot use the locale
56 module."
57
58=cut
59
60# A separate bit is used for each of the two forms of the pragma, as they are
61# mostly independent, and interact with each other and the unicode_strings
62# feature. This allows for fast determination of which one(s) of the three
63# are to be used at any given point, and no code has to be written to deal
64# with coming in and out of scopes--it falls automatically out from the hint
65# handling
66
671100ns$locale::hint_bits = 0x4;
6810s$locale::not_chars_hint_bits = 0x10;
69
70
# spent 50µs (12+38) within locale::import which was called: # once (12µs+38µs) by Pod::Spell::BEGIN@17 at line 17 of Pod/Spell.pm
sub import {
711100ns shift; # should be 'locale'; not checked
72
7315µs138µs if(!$Config{d_setlocale}) {
# spent 38µs making 1 call to Config::FETCH
74 ## No locale support found on this Perl, giving up:
75 die('Your vendor does not support locales, you cannot use the locale module.');
76 }
77
781200ns my $found_not_chars = 0;
791500ns while (defined (my $arg = shift)) {
80 if ($arg eq ":not_characters") {
81 $^H |= $locale::not_chars_hint_bits;
82
83 # This form of the pragma overrides the other
84 $^H &= ~$locale::hint_bits;
85 $found_not_chars = 1;
86 }
87 else {
88 require Carp;
89 Carp::croak("Unknown parameter '$arg' to 'use locale'");
90 }
91 }
92
93 # Use the plain form if not doing the :not_characters one.
9414µs $^H |= $locale::hint_bits unless $found_not_chars;
95}
96
97sub unimport {
98 $^H &= ~($locale::hint_bits|$locale::not_chars_hint_bits);
99}
100
10112µs1;