line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pragmatic; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.001; # ?? |
4
|
|
|
|
|
|
|
require Exporter; |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
5579
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
211
|
|
7
|
6
|
|
|
6
|
|
29
|
use vars qw (@ISA $VERSION); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
1766
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@ISA = qw (Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# The package version, both in 1.23 style *and* usable by MakeMaker: |
12
|
|
|
|
|
|
|
$VERSION = '1.7'; |
13
|
|
|
|
|
|
|
my $rcs = '$Id: Pragmatic.pm 164 2005-03-15 21:42:20Z binkley $' ; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import ($) { |
17
|
14
|
|
|
14
|
|
4539
|
my $package = shift; |
18
|
|
|
|
|
|
|
|
19
|
14
|
100
|
|
|
|
134
|
return $package->export_to_level (1, $package, @_) |
20
|
|
|
|
|
|
|
if $package eq __PACKAGE__; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $warn = sub (;$) { |
23
|
0
|
|
|
0
|
|
0
|
require Carp; |
24
|
0
|
|
|
|
|
0
|
local $Carp::CarpLevel = 2; # relocate to calling package |
25
|
0
|
|
|
|
|
0
|
Carp::carp (@_); |
26
|
13
|
|
|
|
|
52
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $die = sub (;$) { |
29
|
0
|
|
|
0
|
|
0
|
require Carp; |
30
|
0
|
|
|
|
|
0
|
local $Carp::CarpLevel = 2; # relocate to calling package |
31
|
0
|
|
|
|
|
0
|
Carp::croak (@_); |
32
|
13
|
|
|
|
|
44
|
}; |
33
|
|
|
|
|
|
|
|
34
|
13
|
|
|
|
|
53
|
my @imports = grep /^[^-]/, @_; |
35
|
13
|
|
|
|
|
36
|
my @pragmata = map { substr($_, 1); } grep /^-/, @_; |
|
9
|
|
|
|
|
33
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Export first, for side-effects (e.g., importing globals, then |
38
|
|
|
|
|
|
|
# setting them with pragmata): |
39
|
13
|
100
|
|
|
|
167
|
$package->export_to_level (1, $package, @imports) |
40
|
|
|
|
|
|
|
if @imports; |
41
|
|
|
|
|
|
|
|
42
|
13
|
|
|
|
|
52
|
for (@pragmata) { |
43
|
6
|
|
|
6
|
|
59
|
no strict qw (refs); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
1904
|
|
44
|
|
|
|
|
|
|
|
45
|
9
|
|
|
|
|
37
|
my ($pragma, $args) = split /=/, $_; |
46
|
9
|
|
100
|
|
|
63
|
my (@args) = split /,/, $args || ''; |
47
|
|
|
|
|
|
|
|
48
|
9
|
50
|
|
|
|
14
|
exists ${"$package\::PRAGMATA"}{$pragma} |
|
9
|
|
|
|
|
276
|
|
49
|
|
|
|
|
|
|
or &$die ("No such pragma '$pragma'"); |
50
|
|
|
|
|
|
|
|
51
|
9
|
50
|
|
|
|
12
|
if (ref ${"$package\::PRAGMATA"}{$pragma} eq 'CODE') { |
|
9
|
0
|
|
|
|
40
|
|
|
0
|
|
|
|
|
|
|
52
|
9
|
50
|
|
|
|
12
|
&{${"$package\::PRAGMATA"}{$pragma}} ($package, @args) |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
159
|
|
53
|
|
|
|
|
|
|
or &$warn ("Pragma '$pragma' failed"); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Let inheritance work for barewords: |
56
|
|
|
|
|
|
|
} elsif (my $ref = $package->can |
57
|
|
|
|
|
|
|
(${"$package\::PRAGMATA"}{$pragma})) { |
58
|
0
|
0
|
|
|
|
|
&$ref ($package, @args) |
59
|
|
|
|
|
|
|
or &$warn ("Pragma '$pragma' failed"); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} else { |
62
|
0
|
|
|
|
|
|
&$die ("Invalid pragma '$pragma'"); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |