File | /usr/local/lib/perl5/5.10.1/vars.pm |
Statements Executed | 879 |
Statement Execution Time | 2.97ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
52 | 52 | 47 | 1.99ms | 2.46ms | import | vars::
495 | 3 | 2 | 469µs | 469µs | CORE:match (opcode) | vars::
1 | 1 | 1 | 218µs | 278µs | BEGIN@7 | vars::
1 | 1 | 1 | 22µs | 22µs | BEGIN@3 | vars::
1 | 1 | 1 | 5µs | 16µs | BEGIN@8 | vars::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package vars; | ||||
2 | |||||
3 | 3 | 48µs | 1 | 22µs | # spent 22µs within vars::BEGIN@3 which was called
# once (22µs+0s) by Scalar::Util::BEGIN@10 at line 3 # spent 22µs making 1 call to vars::BEGIN@3 |
4 | |||||
5 | 1 | 600ns | our $VERSION = '1.01'; | ||
6 | |||||
7 | 3 | 230µs | 2 | 338µs | # spent 278µs (218+60) within vars::BEGIN@7 which was called
# once (218µs+60µs) by Scalar::Util::BEGIN@10 at line 7 # spent 278µs making 1 call to vars::BEGIN@7
# spent 60µs making 1 call to warnings::register::import |
8 | 3 | 237µs | 2 | 28µs | # spent 16µs (5+11) within vars::BEGIN@8 which was called
# once (5µs+11µs) by Scalar::Util::BEGIN@10 at line 8 # spent 16µs making 1 call to vars::BEGIN@8
# spent 11µs making 1 call to strict::import |
9 | |||||
10 | # spent 2.46ms (1.99+469µs) within vars::import which was called 52 times, avg 47µs/call:
# once (112µs+22µs) by Test::Deep::BEGIN@24 at line 24 of Test/Deep.pm
# once (87µs+19µs) by DateTime::Format::Strptime::BEGIN@12 at line 12 of DateTime/Format/Strptime.pm
# once (78µs+26µs) by Cwd::BEGIN@172 at line 172 of Cwd.pm
# once (78µs+15µs) by Params::Validate::BEGIN@7 at line 7 of Params/Validate.pm
# once (57µs+18µs) by DateTime::TimeZone::Catalog::BEGIN@12 at line 12 of DateTime/TimeZone/Catalog.pm
# once (55µs+17µs) by Try::Tiny::BEGIN@6 at line 6 of Try/Tiny.pm
# once (51µs+19µs) by IO::Select::BEGIN@11 at line 11 of IO/Select.pm
# once (55µs+15µs) by Clone::BEGIN@6 at line 6 of Clone.pm
# once (56µs+13µs) by Time::HiRes::BEGIN@4 at line 4 of Time/HiRes.pm
# once (55µs+12µs) by Digest::SHA::BEGIN@7 at line 7 of Digest/SHA.pm
# once (54µs+12µs) by Storable::BEGIN@24 at line 24 of Storable.pm
# once (53µs+12µs) by Carp::Clan::BEGIN@17 at line 17 of Carp/Clan.pm
# once (49µs+12µs) by List::MoreUtils::BEGIN@8 at line 8 of List/MoreUtils.pm
# once (49µs+10µs) by namespace::clean::BEGIN@12 at line 12 of namespace/clean.pm
# once (49µs+9µs) by Time::Local::BEGIN@9 at line 9 of Time/Local.pm
# once (48µs+10µs) by HTTP::Status::BEGIN@6 at line 6 of HTTP/Status.pm
# once (48µs+10µs) by POSIX::SigRt::BEGIN@66 at line 66 of POSIX.pm
# once (48µs+10µs) by URI::Escape::BEGIN@141 at line 141 of URI/Escape.pm
# once (46µs+10µs) by List::Util::BEGIN@12 at line 12 of List/Util.pm
# once (46µs+9µs) by Scalar::Util::BEGIN@10 at line 10 of Scalar/Util.pm
# once (44µs+9µs) by Params::Util::BEGIN@65 at line 65 of Params/Util.pm
# once (41µs+9µs) by URI::BEGIN@13 at line 13 of URI.pm
# once (41µs+9µs) by Digest::MD5::BEGIN@4 at line 4 of Digest/MD5.pm
# once (40µs+8µs) by XML::Bare::BEGIN@5 at line 5 of XML/Bare.pm
# once (37µs+6µs) by LWP::UserAgent::BEGIN@4 at line 4 of LWP/UserAgent.pm
# once (32µs+7µs) by Class::ISA::BEGIN@4 at line 4 of Class/ISA.pm
# once (26µs+13µs) by base::BEGIN@4 at line 4 of base.pm
# once (31µs+8µs) by HTTP::Date::BEGIN@14 at line 14 of HTTP/Date.pm
# once (31µs+7µs) by MIME::Base64::BEGIN@4 at line 4 of MIME/Base64.pm
# once (32µs+6µs) by File::Spec::BEGIN@4 at line 4 of File/Spec.pm
# once (31µs+7µs) by Net::HTTP::BEGIN@4 at line 4 of Net/HTTP.pm
# once (29µs+8µs) by constant::BEGIN@6 at line 6 of constant.pm
# once (29µs+6µs) by URI::BEGIN@7 at line 7 of URI.pm
# once (27µs+6µs) by LWP::Protocol::http::BEGIN@9 at line 9 of LWP/Protocol/http.pm
# once (25µs+5µs) by DateTime::TimeZone::Floating::BEGIN@5 at line 5 of DateTime/TimeZone/Floating.pm
# once (24µs+6µs) by Devel::GlobalDestruction::BEGIN@8 at line 8 of Devel/GlobalDestruction.pm
# once (24µs+5µs) by HTTP::Config::BEGIN@5 at line 5 of HTTP/Config.pm
# once (23µs+6µs) by LWP::ConnCache::BEGIN@4 at line 4 of LWP/ConnCache.pm
# once (24µs+5µs) by Net::HTTP::Methods::BEGIN@6 at line 6 of Net/HTTP/Methods.pm
# once (22µs+5µs) by Class::Data::Inheritable::BEGIN@4 at line 4 of Class/Data/Inheritable.pm
# once (22µs+5µs) by HTTP::Headers::BEGIN@6 at line 6 of HTTP/Headers.pm
# once (22µs+5µs) by HTTP::Message::BEGIN@4 at line 4 of HTTP/Message.pm
# once (22µs+5µs) by XML::Bare::BEGIN@15 at line 15 of XML/Bare.pm
# once (22µs+5µs) by Digest::base::BEGIN@4 at line 4 of Digest/base.pm
# once (20µs+6µs) by LWP::Protocol::http::Socket::BEGIN@472 at line 472 of LWP/Protocol/http.pm
# once (16µs+4µs) by Test::Deep::RegexpVersion::BEGIN@6 at line 6 of Test/Deep/RegexpVersion.pm
# once (15µs+4µs) by DateTime::TimeZone::OffsetOnly::BEGIN@5 at line 5 of DateTime/TimeZone/OffsetOnly.pm
# once (14µs+4µs) by URI::BEGIN@4 at line 4 of URI.pm
# once (14µs+4µs) by DateTime::TimeZone::Local::BEGIN@6 at line 6 of DateTime/TimeZone/Local.pm
# once (14µs+3µs) by DateTime::TimeZone::UTC::BEGIN@5 at line 5 of DateTime/TimeZone/UTC.pm
# once (14µs+3µs) by File::Spec::Unix::BEGIN@4 at line 4 of File/Spec/Unix.pm
# once (13µs+3µs) by URI::Escape::BEGIN@142 at line 142 of URI/Escape.pm | ||||
11 | 868 | 2.45ms | my $callpack = caller; | ||
12 | my ($pack, @imports) = @_; | ||||
13 | my ($sym, $ch); | ||||
14 | foreach (@imports) { | ||||
15 | if (($ch, $sym) = /^([\$\@\%\*\&])(.+)/) { # spent 335µs making 165 calls to vars::CORE:match, avg 2µs/call | ||||
16 | if ($sym =~ /\W/) { # spent 63µs making 165 calls to vars::CORE:match, avg 385ns/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 70µs making 165 calls to vars::CORE:match, avg 424ns/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 | 3µ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 469µs within vars::CORE:match which was called 495 times, avg 947ns/call:
# 165 times (335µs+0s) by vars::import at line 15 of vars.pm, avg 2µs/call
# 165 times (70µs+0s) by vars::import at line 28 of vars.pm, avg 424ns/call
# 165 times (63µs+0s) by vars::import at line 16 of vars.pm, avg 385ns/call |