File | /usr/local/lib/perl5/5.8.8/vars.pm |
Statements Executed | 695 |
Statement Execution Time | 14.4ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
45 | 45 | 39 | 10.1ms | 12.6ms | import | vars::
378 | 3 | 2 | 2.52ms | 2.52ms | CORE:match (opcode) | vars::
0 | 0 | 0 | 0s | 0s | BEGIN | vars::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package vars; | ||||
2 | |||||
3 | 3 | 101µs | use 5.006; | ||
4 | |||||
5 | 1 | 6µs | our $VERSION = '1.01'; | ||
6 | |||||
7 | 3 | 737µs | 1 | 650µs | use warnings::register; # spent 650µs making 1 call to warnings::register::import |
8 | 3 | 702µs | 1 | 167µs | use strict qw(vars subs); # spent 167µs making 1 call to strict::import |
9 | |||||
10 | # spent 12.6ms (10.1+2.51) within vars::import which was called 45 times, avg 280µs/call:
# once (1.01ms+263µs) by Class::DBI::_require_class at line 7 of Class/Date.pm
# once (587µs+155µs) by DBI::install_driver at line 25 of DBD/Pg.pm
# once (351µs+116µs) by base::import at line 12 of List/Util.pm
# once (335µs+86µs) by base::import at line 6 of Clone.pm
# once (320µs+93µs) by URI::BEGIN at line 13 of URI.pm
# once (321µs+76µs) by HTTP::Status::BEGIN at line 8 of HTTP/Status.pm
# once (295µs+95µs) by Class::DBI::_require_class at line 9 of Time/Local.pm
# once (317µs+73µs) by Class::DBI::_require_class at line 4 of Class/Date/Const.pm
# once (309µs+76µs) by URI::Escape::BEGIN at line 145 of URI/Escape.pm
# once (305µs+75µs) by base::import at line 16 of DBI/Const/GetInfoType.pm
# once (300µs+77µs) by LWP::UserAgent::get at line 6 of HTTP/Request/Common.pm
# once (294µs+74µs) by base::import at line 10 of Scalar/Util.pm
# once (294µs+68µs) by LWP::Protocol::collect at line 134 of HTML/Entities.pm
# once (281µs+74µs) by base::import at line 7 of version.pm
# once (259µs+55µs) by HTTP::Date::BEGIN at line 14 of HTTP/Date.pm
# once (225µs+53µs) by base::import at line 8 of version/vxs.pm
# once (219µs+57µs) by base::import at line 24 of Storable.pm
# once (199µs+41µs) by LWP::Protocol::collect at line 10 of HTML/Parser.pm
# once (194µs+42µs) by base::import at line 18 of DynaLoader.pm
# once (184µs+43µs) by HTTP::Headers::BEGIN at line 8 of HTTP/Headers.pm
# once (180µs+45µs) by base::import at line 4 of Class/DBI/AbstractSearch.pm
# once (167µs+58µs) by URI::BEGIN at line 7 of URI.pm
# once (179µs+43µs) by HTTP::Message::BEGIN at line 6 of HTTP/Message.pm
# once (171µs+48µs) by LWP::Protocol::implementor at line 13 of LWP/Protocol/http.pm
# once (171µs+46µs) by base::import at line 4 of File/Spec.pm
# once (178µs+37µs) by LWP::Protocol::collect at line 135 of HTML/Entities.pm
# once (170µs+44µs) by IO::Socket::connect at line 11 of IO/Select.pm
# once (170µs+41µs) by LWP::UserAgent::BEGIN at line 6 of LWP/UserAgent.pm
# once (166µs+44µs) by LWP::Protocol::collect at line 77 of HTML/HeadParser.pm
# once (168µs+39µs) by LWP::Protocol::implementor at line 6 of Net/HTTP.pm
# once (128µs+30µs) by base::BEGIN at line 4 of base.pm
# once (132µs+25µs) by base::import at line 7 of Data/Page.pm
# once (132µs+24µs) by LWP::Protocol::implementor at line 8 of Net/HTTP/Methods.pm
# once (124µs+25µs) by LWP::Protocol::implementor at line 416 of LWP/Protocol/http.pm
# once (121µs+28µs) by WWW::Google::PageRank::BEGIN at line 8 of WWW/Google/PageRank.pm
# once (118µs+25µs) by URI::BEGIN at line 4 of URI.pm
# once (116µs+27µs) by base::import at line 24 of Class/DBI.pm
# once (116µs+25µs) by base::import at line 11 of Class/DBI/Plugin/Pager.pm
# once (115µs+26µs) by base::import at line 6 of Class/DBI/Pg.pm
# once (115µs+25µs) by Class::DBI::_require_class at line 588 of Class/Date.pm
# once (110µs+27µs) by base::import at line 4 of Class/Trigger.pm
# once (113µs+24µs) by base::import at line 4 of Class/Data/Inheritable.pm
# once (112µs+22µs) by base::import at line 4 of File/Spec/Unix.pm
# once (110µs+21µs) by URI::Escape::BEGIN at line 146 of URI/Escape.pm
# once (106µs+24µs) by base::import at line 13 of UNIVERSAL/require.pm | ||||
11 | 180 | 2.10ms | my $callpack = caller; | ||
12 | my ($pack, @imports) = @_; | ||||
13 | my ($sym, $ch); | ||||
14 | foreach (@imports) { | ||||
15 | 504 | 10.8ms | 126 | 1.16ms | if (($ch, $sym) = /^([\$\@\%\*\&])(.+)/) { # spent 1.16ms making 126 calls to vars::CORE:match, avg 9µs/call |
16 | if ($sym =~ /\W/) { # spent 719µs making 126 calls to vars::CORE:match, avg 6µs/call | ||||
17 | # time for a more-detailed check-up | ||||
18 | if ($sym =~ /^\w+[[{].*[]}]$/) { | ||||
19 | require Carp; | ||||
20 | Carp::croak("Can't declare individual elements of hash or array"); | ||||
21 | } elsif (warnings::enabled() and length($sym) == 1 and $sym !~ tr/a-zA-Z//) { | ||||
22 | warnings::warn("No need to declare built-in vars"); | ||||
23 | } elsif (($^H &= strict::bits('vars'))) { | ||||
24 | require Carp; | ||||
25 | Carp::croak("'$_' is not a valid variable name under strict vars"); | ||||
26 | } | ||||
27 | } | ||||
28 | $sym = "${callpack}::$sym" unless $sym =~ /::/; # spent 637µs making 126 calls to vars::CORE:match, avg 5µs/call | ||||
29 | *$sym = | ||||
30 | ( $ch eq "\$" ? \$$sym | ||||
31 | : $ch eq "\@" ? \@$sym | ||||
32 | : $ch eq "\%" ? \%$sym | ||||
33 | : $ch eq "\*" ? \*$sym | ||||
34 | : $ch eq "\&" ? \&$sym | ||||
35 | : do { | ||||
36 | require Carp; | ||||
37 | Carp::croak("'$_' is not a valid variable name"); | ||||
38 | }); | ||||
39 | } else { | ||||
40 | require Carp; | ||||
41 | Carp::croak("'$_' is not a valid variable name"); | ||||
42 | } | ||||
43 | } | ||||
44 | }; | ||||
45 | |||||
46 | 1 | 13µs | 1; | ||
47 | __END__ | ||||
48 | |||||
49 | =head1 NAME | ||||
50 | |||||
51 | vars - Perl pragma to predeclare global variable names (obsolete) | ||||
52 | |||||
53 | =head1 SYNOPSIS | ||||
54 | |||||
55 | use vars qw($frob @mung %seen); | ||||
56 | |||||
57 | =head1 DESCRIPTION | ||||
58 | |||||
59 | NOTE: For variables in the current package, the functionality provided | ||||
60 | by this pragma has been superseded by C<our> declarations, available | ||||
61 | in Perl v5.6.0 or later. See L<perlfunc/our>. | ||||
62 | |||||
63 | This will predeclare all the variables whose names are | ||||
64 | in the list, allowing you to use them under "use strict", and | ||||
65 | disabling any typo warnings. | ||||
66 | |||||
67 | Unlike pragmas that affect the C<$^H> hints variable, the C<use vars> and | ||||
68 | C<use subs> declarations are not BLOCK-scoped. They are thus effective | ||||
69 | for the entire file in which they appear. You may not rescind such | ||||
70 | declarations with C<no vars> or C<no subs>. | ||||
71 | |||||
72 | Packages such as the B<AutoLoader> and B<SelfLoader> that delay | ||||
73 | loading of subroutines within packages can create problems with | ||||
74 | package lexicals defined using C<my()>. While the B<vars> pragma | ||||
75 | cannot duplicate the effect of package lexicals (total transparency | ||||
76 | outside of the package), it can act as an acceptable substitute by | ||||
77 | pre-declaring global symbols, ensuring their availability to the | ||||
78 | later-loaded routines. | ||||
79 | |||||
80 | See L<perlmodlib/Pragmatic Modules>. | ||||
81 | |||||
82 | =cut | ||||
# spent 2.52ms within vars::CORE:match which was called 378 times, avg 7µs/call:
# 126 times (1.16ms+0s) by vars::import at line 15 of vars.pm, avg 9µs/call
# 126 times (719µs+0s) by vars::import at line 16 of vars.pm, avg 6µs/call
# 126 times (637µs+0s) by vars::import at line 28 of vars.pm, avg 5µs/call |