line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Damn; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
143932
|
use 5.000; |
|
6
|
|
|
|
|
52
|
|
4
|
6
|
|
|
6
|
|
30
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
195
|
|
5
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
195
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
26
|
use Exporter; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
424
|
|
8
|
6
|
|
|
6
|
|
33
|
use DynaLoader qw( AUTOLOAD ); |
|
6
|
|
|
|
|
23
|
|
|
6
|
|
|
|
|
331
|
|
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
30
|
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK ); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
3015
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = '0.08'; |
13
|
|
|
|
|
|
|
@ISA = qw( Exporter DynaLoader ); |
14
|
|
|
|
|
|
|
@EXPORT = qw( damn ); |
15
|
|
|
|
|
|
|
@EXPORT_OK = qw( bless ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# ensure we aren't exposed to changes in inherited AUTOLOAD behaviour |
18
|
|
|
|
|
|
|
*Acme::Damn::AUTOLOAD = *DynaLoader::AUTOLOAD; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub import |
22
|
|
|
|
|
|
|
{ |
23
|
9
|
|
|
9
|
|
1650
|
my $class = shift; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# check the unknown symbols to ensure they are 'safe' |
26
|
9
|
|
|
|
|
22
|
my @bad = grep { /\W/o } @_; |
|
26
|
|
|
|
|
56
|
|
27
|
9
|
100
|
|
|
|
64
|
if ( @bad ) { |
28
|
|
|
|
|
|
|
# throw an error message informing the user where the problem is |
29
|
3
|
|
|
|
|
29
|
my ( undef, $file , $line ) = caller 0; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
die sprintf( "Bad choice of symbol name%s %s for import at %s line %s\n" |
32
|
|
|
|
|
|
|
, ( @bad == 1 ) ? '' : 's' |
33
|
3
|
50
|
|
|
|
146
|
, join( ', ' , map { qq|'$_'| } @bad ) , $file , $line ); |
|
3
|
|
|
|
|
54
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# remove duplicates from the list of aliases, as well as those symbol |
37
|
|
|
|
|
|
|
# names listed in @EXPORT |
38
|
|
|
|
|
|
|
# - we keep @EXPORT_OK in a separate list since they are optionally |
39
|
|
|
|
|
|
|
# requested at use() time |
40
|
6
|
|
|
|
|
8
|
my @aliases = do { local %_; |
|
6
|
|
|
|
|
14
|
|
41
|
6
|
|
|
|
|
29
|
@_{ @_ } = undef; |
42
|
6
|
|
|
|
|
16
|
delete @_{ @EXPORT }; |
43
|
6
|
|
|
|
|
38
|
keys %_ |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# 'import' the symbols into the host package |
47
|
|
|
|
|
|
|
# - ensure 'EXPORT_OK' is correctly honoured |
48
|
6
|
|
|
|
|
13
|
my %reserved = map { $_ => 1 } @EXPORT , @EXPORT_OK; |
|
12
|
|
|
|
|
40
|
|
49
|
6
|
|
|
|
|
13
|
my @reserved = (); |
50
|
6
|
|
|
|
|
42
|
my ( $pkg ) = caller 1; |
51
|
6
|
|
|
|
|
126
|
foreach my $alias ( @aliases ) { |
52
|
|
|
|
|
|
|
# if this alias is a reserved symbol as defined by @EXPORT et al. |
53
|
|
|
|
|
|
|
# then add it to the list of symbols to export |
54
|
21
|
100
|
66
|
|
|
59
|
$reserved{ $alias } |
55
|
|
|
|
|
|
|
and push @reserved , $alias |
56
|
|
|
|
|
|
|
and next; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# otherwise, create an alias for 'damn' |
59
|
6
|
|
|
6
|
|
38
|
no strict 'refs'; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
1292
|
|
60
|
|
|
|
|
|
|
|
61
|
20
|
|
|
|
|
57
|
*{ $pkg . '::' . $alias } = sub { |
62
|
30
|
|
|
30
|
|
15925
|
my $ref = shift; |
63
|
30
|
|
|
|
|
65
|
my ( undef , $file , $line ) = caller 1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# call damn() with the location of where this method was |
66
|
|
|
|
|
|
|
# originally called |
67
|
30
|
|
|
|
|
1179
|
&{ __PACKAGE__ . '::damn' }( $ref , $alias , $file , $line ); |
|
30
|
|
|
|
|
268
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# NB: wanted to do something like |
70
|
|
|
|
|
|
|
# goto \&{ __PACKAGE__ . '::damn' }; |
71
|
|
|
|
|
|
|
# having set the @_ array appropriately, but this caused a |
72
|
|
|
|
|
|
|
# "Attempt to free unrefernced SV" error that I couldn't solve |
73
|
|
|
|
|
|
|
# - I think it was to do with the @_ array |
74
|
20
|
|
|
|
|
58
|
}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# add the known symbols to @_ |
78
|
6
|
|
|
|
|
19
|
splice @_ , 0; push @_ , $class , @reserved; |
|
6
|
|
|
|
|
17
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# run the "proper" import() routine |
81
|
6
|
|
|
|
|
6204
|
goto \&Exporter::import; |
82
|
|
|
|
|
|
|
} # import() |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
bootstrap Acme::Damn $VERSION; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; # end of module |
89
|
|
|
|
|
|
|
__END__ |