← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:04 2021

Filename/usr/local/lib/perl5/site_perl/Sub/Exporter/Progressive.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sSub::Exporter::Progressive::::BEGIN@20Sub::Exporter::Progressive::BEGIN@20
0000s0sSub::Exporter::Progressive::::BEGIN@21Sub::Exporter::Progressive::BEGIN@21
0000s0sSub::Exporter::Progressive::::BEGIN@26Sub::Exporter::Progressive::BEGIN@26
0000s0sSub::Exporter::Progressive::::BEGIN@3Sub::Exporter::Progressive::BEGIN@3
0000s0sSub::Exporter::Progressive::::BEGIN@4Sub::Exporter::Progressive::BEGIN@4
0000s0sSub::Exporter::Progressive::::CORE:matchSub::Exporter::Progressive::CORE:match (opcode)
0000s0sSub::Exporter::Progressive::::CORE:substSub::Exporter::Progressive::CORE:subst (opcode)
0000s0sSub::Exporter::Progressive::::__ANON__[:47]Sub::Exporter::Progressive::__ANON__[:47]
0000s0sSub::Exporter::Progressive::::_croakSub::Exporter::Progressive::_croak
0000s0sSub::Exporter::Progressive::::importSub::Exporter::Progressive::import
0000s0sSub::Exporter::Progressive::::sub_export_optionsSub::Exporter::Progressive::sub_export_options
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Sub::Exporter::Progressive;
2$Sub::Exporter::Progressive::VERSION = '0.001013';
3use strict;
4use warnings;
5
6# ABSTRACT: Only use Sub::Exporter if you need it
7
8sub _croak {
9 require Carp;
10 &Carp::croak;
11}
12
13sub import {
14 my ($self, @args) = @_;
15
16 my $inner_target = caller;
17 my $export_data = sub_export_options($inner_target, @args);
18
19 my $full_exporter;
20 no strict 'refs';
21 no warnings 'once';
22 @{"${inner_target}::EXPORT_OK"} = @{$export_data->{exports}};
23 @{"${inner_target}::EXPORT"} = @{$export_data->{defaults}};
24 %{"${inner_target}::EXPORT_TAGS"} = %{$export_data->{tags}};
25 *{"${inner_target}::import"} = sub {
26 use strict;
27 my ($self, @args) = @_;
28
29 if ( grep {
30 length ref $_
31 or
32 $_ !~ / \A [:-]? \w+ \z /xm
33 } @args ) {
34 _croak 'your usage of Sub::Exporter::Progressive requires Sub::Exporter to be installed'
35 unless eval { require Sub::Exporter };
36 $full_exporter ||= Sub::Exporter::build_exporter($export_data->{original});
37
38 goto $full_exporter;
39 } elsif ( defined( (my ($num) = grep { m/^\d/ } @args)[0] ) ) {
40 _croak "cannot export symbols with a leading digit: '$num'";
41 } else {
42 require Exporter;
43 s/ \A - /:/xm for @args;
44 @_ = ($self, @args);
45 goto \&Exporter::import;
46 }
47 };
48 return;
49}
50
51my $too_complicated = <<'DEATH';
52You are using Sub::Exporter::Progressive, but the features your program uses from
53Sub::Exporter cannot be implemented without Sub::Exporter, so you might as well
54just use vanilla Sub::Exporter
55DEATH
56
57sub sub_export_options {
58 my ($inner_target, $setup, $options) = @_;
59
60 my @exports;
61 my @defaults;
62 my %tags;
63
64 if ( ($setup||'') eq '-setup') {
65 my %options = %$options;
66
67 OPTIONS:
68 for my $opt (keys %options) {
69 if ($opt eq 'exports') {
70
71 _croak $too_complicated if ref $options{exports} ne 'ARRAY';
72 @exports = @{$options{exports}};
73 _croak $too_complicated if grep { length ref $_ } @exports;
74
75 } elsif ($opt eq 'groups') {
76 %tags = %{$options{groups}};
77 for my $tagset (values %tags) {
78 _croak $too_complicated if grep {
79 length ref $_
80 or
81 $_ =~ / \A - (?! all \b ) /x
82 } @{$tagset};
83 }
84 @defaults = @{$tags{default} || [] };
85 } else {
86 _croak $too_complicated;
87 }
88 }
89 @{$_} = map { / \A [:-] all \z /x ? @exports : $_ } @{$_} for \@defaults, values %tags;
90 $tags{all} ||= [ @exports ];
91 my %exports = map { $_ => 1 } @exports;
92 my @errors = grep { not $exports{$_} } @defaults;
93 _croak join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors;
94 }
95
96 return {
97 exports => \@exports,
98 defaults => \@defaults,
99 original => $options,
100 tags => \%tags,
101 };
102}
103
1041;
105
106__END__