← Index
NYTProf Performance Profile   « line view »
For -e
  Run on Thu Jun 30 16:16:00 2016
Reported on Thu Jun 30 16:16:08 2016

Filename/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/DateTime/Locale/Util.pm
StatementsExecuted 9 statements in 373µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11128µs31µsDateTime::Locale::Util::::BEGIN@3DateTime::Locale::Util::BEGIN@3
11111µs23µsDateTime::Locale::Util::::BEGIN@6DateTime::Locale::Util::BEGIN@6
1119µs15µsDateTime::Locale::Util::::BEGIN@4DateTime::Locale::Util::BEGIN@4
0000s0sDateTime::Locale::Util::::_tcDateTime::Locale::Util::_tc
0000s0sDateTime::Locale::Util::::parse_locale_codeDateTime::Locale::Util::parse_locale_code
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DateTime::Locale::Util;
2
3236µs235µs
# spent 31µs (28+4) within DateTime::Locale::Util::BEGIN@3 which was called: # once (28µs+4µs) by DateTime::Locale::FromData::BEGIN@6 at line 3
use strict;
# spent 31µs making 1 call to DateTime::Locale::Util::BEGIN@3 # spent 4µs making 1 call to strict::import
4232µs222µs
# spent 15µs (9+7) within DateTime::Locale::Util::BEGIN@4 which was called: # once (9µs+7µs) by DateTime::Locale::FromData::BEGIN@6 at line 4
use warnings;
# spent 15µs making 1 call to DateTime::Locale::Util::BEGIN@4 # spent 6µs making 1 call to warnings::import
5
62299µs235µs
# spent 23µs (11+12) within DateTime::Locale::Util::BEGIN@6 which was called: # once (11µs+12µs) by DateTime::Locale::FromData::BEGIN@6 at line 6
use Exporter qw( import );
# spent 23µs making 1 call to DateTime::Locale::Util::BEGIN@6 # spent 12µs making 1 call to Exporter::import
7
81600nsour $VERSION = '1.03';
9
1011µsour @EXPORT_OK = 'parse_locale_code';
11
12sub parse_locale_code {
13 my @pieces = split /-/, $_[0];
14
15 return unless @pieces;
16
17 my %codes = ( language => lc shift @pieces );
18 if ( @pieces == 1 ) {
19 if ( length $pieces[0] == 2 || $pieces[0] =~ /^\d\d\d$/ ) {
20 $codes{territory} = uc shift @pieces;
21 }
22 }
23 elsif ( @pieces == 3 ) {
24 $codes{script} = _tc( shift @pieces );
25 $codes{territory} = uc shift @pieces;
26 $codes{variant} = uc shift @pieces;
27 }
28 elsif ( @pieces == 2 ) {
29
30 # I don't think it's possible to have a script + variant with also
31 # having a territory.
32 if ( length $pieces[1] == 2 || $pieces[1] =~ /^\d\d\d$/ ) {
33 $codes{script} = _tc( shift @pieces );
34 $codes{territory} = uc shift @pieces;
35 }
36 else {
37 $codes{territory} = uc shift @pieces;
38 $codes{variant} = uc shift @pieces;
39 }
40 }
41
42 return %codes;
43}
44
45sub _tc {
46 return ucfirst lc $_[0];
47}
48
4915µs1;
50
51# ABSTRACT: Utility code for DateTime::Locale
52
53__END__