| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PERLANCAR::Exporter::Lite; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2016-03-13'; # DATE |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Be lean. |
|
7
|
|
|
|
|
|
|
#use strict; |
|
8
|
|
|
|
|
|
|
#use warnings; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import { |
|
11
|
1
|
|
|
1
|
|
5
|
my $pkg0 = shift; |
|
12
|
1
|
50
|
33
|
|
|
8
|
if (@_ && $_[0] eq 'import') { |
|
13
|
1
|
|
|
|
|
4
|
my $exporter = caller; |
|
14
|
1
|
|
|
|
|
102
|
*{"$exporter\::import"} = sub { |
|
15
|
7
|
|
|
7
|
|
4470
|
my $pkg = shift; |
|
16
|
7
|
|
|
|
|
12
|
my $caller = caller; |
|
17
|
7
|
100
|
|
|
|
156
|
my @exp = @_ ? @_ : @{"$exporter\::EXPORT"}; |
|
|
1
|
|
|
|
|
3
|
|
|
18
|
7
|
|
|
|
|
11
|
for my $exp (@exp) { |
|
19
|
7
|
100
|
|
|
|
7
|
unless (grep {$_ eq $exp} (@{"$exporter\::EXPORT"}, |
|
|
42
|
|
|
|
|
53
|
|
|
|
7
|
|
|
|
|
16
|
|
|
20
|
7
|
|
|
|
|
9
|
@{"$exporter\::EXPORT_OK"})) { |
|
21
|
1
|
|
|
|
|
9
|
die "$exp is not exported by $exporter"; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
6
|
100
|
|
|
|
37
|
if ($exp =~ /\A\$(.+)/) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
3
|
*{"$caller\::$1"} = \${"$exporter\::$1"}; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
4
|
|
|
25
|
|
|
|
|
|
|
} elsif ($exp =~ /\A\@(.+)/) { |
|
26
|
1
|
|
|
|
|
3
|
*{"$caller\::$1"} = \@{"$exporter\::$1"}; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
4
|
|
|
27
|
|
|
|
|
|
|
} elsif ($exp =~ /\A\%(.+)/) { |
|
28
|
1
|
|
|
|
|
2
|
*{"$caller\::$1"} = \%{"$exporter\::$1"}; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
3
|
|
|
29
|
|
|
|
|
|
|
} elsif ($exp =~ /\A\*(\w+)\z/) { |
|
30
|
1
|
|
|
|
|
2
|
*{"$caller\::$1"} = *{"$exporter\::$1"}; |
|
|
1
|
|
|
|
|
36
|
|
|
|
1
|
|
|
|
|
6
|
|
|
31
|
|
|
|
|
|
|
} elsif ($exp =~ /\A&?(\w+)\z/) { |
|
32
|
2
|
|
|
|
|
2
|
*{"$caller\::$1"} = \&{"$exporter\::$1"}; |
|
|
2
|
|
|
|
|
12
|
|
|
|
2
|
|
|
|
|
5
|
|
|
33
|
|
|
|
|
|
|
} else { |
|
34
|
0
|
|
|
|
|
|
die "Invalid export '$exp'"; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
} |
|
37
|
1
|
|
|
|
|
14
|
}; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
|
42
|
|
|
|
|
|
|
# ABSTRACT: A stripped down Exporter |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=encoding UTF-8 |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
PERLANCAR::Exporter::Lite - A stripped down Exporter |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 VERSION |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This document describes version 0.02 of PERLANCAR::Exporter::Lite (from Perl distribution PERLANCAR-Exporter-Lite), released on 2016-03-13. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
In F<lib/YourModule.pm>: |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
package YourModule; |
|
63
|
|
|
|
|
|
|
use PERLANCAR::Exporter::Lite qw(import); |
|
64
|
|
|
|
|
|
|
our @EXPORT = qw(...); |
|
65
|
|
|
|
|
|
|
our @EXPORT_OK = qw(...); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This is a stripped down exporter module, to achieve the smallest startup |
|
70
|
|
|
|
|
|
|
overhead (see L<Bencher::Scenario::Exporters::Startup> for benchmark). This is |
|
71
|
|
|
|
|
|
|
what I think L<Exporter::Lite> should be. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This module offers only some features of L<Exporter>: default exports via |
|
74
|
|
|
|
|
|
|
C<@EXPORT> and optional exports via C<@EXPORT_OK>. You can only use this |
|
75
|
|
|
|
|
|
|
exporter by importing its C<import> and not by subclassing. There is no support |
|
76
|
|
|
|
|
|
|
for export tags, C<export_to_level>, etc. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 HOMEPAGE |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/PERLANCAR-Exporter-Lite>. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SOURCE |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-PERLANCAR-Exporter-Lite>. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 BUGS |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=PERLANCAR-Exporter-Lite> |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
|
91
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
|
92
|
|
|
|
|
|
|
feature. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
L<Exporter> |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This software is copyright (c) 2016 by perlancar@cpan.org. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
107
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |