File | /usr/local/lib/perl5/5.10.1/vars.pm |
Statements Executed | 543 |
Statement Execution Time | 2.35ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
36 | 36 | 31 | 1.37ms | 1.73ms | import | vars::
291 | 3 | 2 | 354µs | 354µs | CORE:match (opcode) | vars::
1 | 1 | 1 | 260µs | 335µs | BEGIN@7 | vars::
1 | 1 | 1 | 29µs | 29µs | BEGIN@3 | vars::
1 | 1 | 1 | 7µs | 22µs | BEGIN@8 | vars::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package vars; | ||||
2 | |||||
3 | 3 | 53µs | 1 | 29µs | # spent 29µs within vars::BEGIN@3 which was called
# once (29µs+0s) by Scalar::Util::BEGIN@10 at line 3 # spent 29µs making 1 call to vars::BEGIN@3 |
4 | |||||
5 | 1 | 800ns | our $VERSION = '1.01'; | ||
6 | |||||
7 | 3 | 277µs | 2 | 410µs | # spent 335µs (260+75) within vars::BEGIN@7 which was called
# once (260µs+75µs) by Scalar::Util::BEGIN@10 at line 7 # spent 335µs making 1 call to vars::BEGIN@7
# spent 75µs making 1 call to warnings::register::import |
8 | 3 | 288µs | 2 | 36µs | # spent 22µs (7+15) within vars::BEGIN@8 which was called
# once (7µs+15µs) by Scalar::Util::BEGIN@10 at line 8 # spent 22µs making 1 call to vars::BEGIN@8
# spent 14µs making 1 call to strict::import |
9 | |||||
10 | # spent 1.73ms (1.37+354µs) within vars::import which was called 36 times, avg 48µs/call:
# once (94µs+26µs) by Params::Util::BEGIN@65 at line 65 of Params/Util.pm
# once (65µs+21µs) by Time::HiRes::BEGIN@4 at line 4 of Time/HiRes.pm
# once (68µs+13µs) by LWP::ConnCache::BEGIN@4 at line 4 of LWP/ConnCache.pm
# once (61µs+18µs) by Try::Tiny::BEGIN@6 at line 6 of Try/Tiny.pm
# once (61µs+14µs) by Scalar::Util::BEGIN@10 at line 10 of Scalar/Util.pm
# once (57µs+18µs) by HTTP::Status::BEGIN@6 at line 6 of HTTP/Status.pm
# once (53µs+15µs) by MIME::Base64::BEGIN@4 at line 4 of MIME/Base64.pm
# once (50µs+13µs) by List::MoreUtils::BEGIN@8 at line 8 of List/MoreUtils.pm
# once (52µs+10µs) by Net::HTTP::BEGIN@4 at line 4 of Net/HTTP.pm
# once (49µs+11µs) by Digest::SHA::BEGIN@7 at line 7 of Digest/SHA.pm
# once (47µs+10µs) by List::Util::BEGIN@12 at line 12 of List/Util.pm
# once (40µs+16µs) by Time::Local::BEGIN@9 at line 9 of Time/Local.pm
# once (39µs+14µs) by constant::BEGIN@6 at line 6 of constant.pm
# once (41µs+9µs) by LWP::Protocol::http::BEGIN@9 at line 9 of LWP/Protocol/http.pm
# once (41µs+8µs) by URI::BEGIN@13 at line 13 of URI.pm
# once (34µs+13µs) by LWP::UserAgent::BEGIN@4 at line 4 of LWP/UserAgent.pm
# once (39µs+8µs) by URI::Escape::BEGIN@141 at line 141 of URI/Escape.pm
# once (39µs+8µs) by XML::Bare::BEGIN@5 at line 5 of XML/Bare.pm
# once (37µs+9µs) by IO::Select::BEGIN@11 at line 11 of IO/Select.pm
# once (35µs+7µs) by Devel::GlobalDestruction::BEGIN@8 at line 8 of Devel/GlobalDestruction.pm
# once (35µs+6µs) by File::Spec::BEGIN@4 at line 4 of File/Spec.pm
# once (33µs+7µs) by Storable::BEGIN@24 at line 24 of Storable.pm
# once (31µs+7µs) by HTTP::Headers::BEGIN@6 at line 6 of HTTP/Headers.pm
# once (30µs+7µs) by HTTP::Date::BEGIN@14 at line 14 of HTTP/Date.pm
# once (25µs+11µs) by base::BEGIN@4 at line 4 of base.pm
# once (28µs+9µs) by HTTP::Message::BEGIN@4 at line 4 of HTTP/Message.pm
# once (28µs+6µs) by URI::BEGIN@7 at line 7 of URI.pm
# once (26µs+7µs) by LWP::Protocol::http::Socket::BEGIN@472 at line 472 of LWP/Protocol/http.pm
# once (24µs+6µs) by XML::Bare::BEGIN@15 at line 15 of XML/Bare.pm
# once (23µs+4µs) by HTTP::Config::BEGIN@5 at line 5 of HTTP/Config.pm
# once (16µs+4µs) by Net::HTTP::Methods::BEGIN@6 at line 6 of Net/HTTP/Methods.pm
# once (15µs+4µs) by File::Spec::Unix::BEGIN@4 at line 4 of File/Spec/Unix.pm
# once (15µs+4µs) by Digest::base::BEGIN@4 at line 4 of Digest/base.pm
# once (14µs+4µs) by Class::Data::Inheritable::BEGIN@4 at line 4 of Class/Data/Inheritable.pm
# once (14µs+3µs) by URI::BEGIN@4 at line 4 of URI.pm
# once (13µs+2µs) by URI::Escape::BEGIN@142 at line 142 of URI/Escape.pm | ||||
11 | 36 | 30µs | my $callpack = caller; | ||
12 | 36 | 69µs | my ($pack, @imports) = @_; | ||
13 | 36 | 11µs | my ($sym, $ch); | ||
14 | 36 | 178µs | foreach (@imports) { | ||
15 | 97 | 681µs | 97 | 253µs | if (($ch, $sym) = /^([\$\@\%\*\&])(.+)/) { # spent 253µs making 97 calls to vars::CORE:match, avg 3µs/call |
16 | 97 | 183µs | 97 | 49µs | if ($sym =~ /\W/) { # spent 49µs making 97 calls to vars::CORE:match, avg 506ns/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 | 97 | 210µs | 97 | 52µs | $sym = "${callpack}::$sym" unless $sym =~ /::/; # spent 52µs making 97 calls to vars::CORE:match, avg 539ns/call |
29 | *$sym = | ||||
30 | ( $ch eq "\$" ? \$$sym | ||||
31 | : $ch eq "\@" ? \@$sym | ||||
32 | : $ch eq "\%" ? \%$sym | ||||
33 | : $ch eq "\*" ? \*$sym | ||||
34 | : $ch eq "\&" ? \&$sym | ||||
35 | 97 | 369µs | : 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 | 4µ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 354µs within vars::CORE:match which was called 291 times, avg 1µs/call:
# 97 times (253µs+0s) by vars::import at line 15 of vars.pm, avg 3µs/call
# 97 times (52µs+0s) by vars::import at line 28 of vars.pm, avg 539ns/call
# 97 times (49µs+0s) by vars::import at line 16 of vars.pm, avg 506ns/call |