line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Section::Simple; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
34312
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
180
|
|
4
|
4
|
|
|
4
|
|
115
|
use 5.008_001; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
518
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
53923
|
use base qw(Exporter); |
|
4
|
|
|
|
|
31
|
|
|
4
|
|
|
|
|
11674
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(get_data_section); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
6
|
|
|
6
|
0
|
42
|
my($class, $pkg) = @_; |
12
|
6
|
|
33
|
|
|
54
|
bless { package => $pkg || caller }, $class; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_data_section { |
16
|
13
|
100
|
|
13
|
0
|
1683
|
my $self = ref $_[0] ? shift : __PACKAGE__->new(scalar caller); |
17
|
|
|
|
|
|
|
|
18
|
13
|
100
|
|
|
|
43
|
if (@_) { |
19
|
5
|
|
|
|
|
28
|
my $all = $self->get_data_section; |
20
|
5
|
100
|
|
|
|
41
|
return unless $all; |
21
|
4
|
|
|
|
|
33
|
return $all->{$_[0]}; |
22
|
|
|
|
|
|
|
} else { |
23
|
4
|
|
|
4
|
|
249
|
my $d = do { no strict 'refs'; \*{$self->{package}."::DATA"} }; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
5013
|
|
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
73
|
|
24
|
8
|
100
|
|
|
|
41
|
return unless defined fileno $d; |
25
|
|
|
|
|
|
|
|
26
|
7
|
|
|
|
|
65
|
seek $d, 0, 0; |
27
|
7
|
|
|
|
|
1855
|
my $content = join '', <$d>; |
28
|
7
|
|
|
|
|
534
|
$content =~ s/^.*\n__DATA__\n/\n/s; # for win32 |
29
|
7
|
|
|
|
|
37
|
$content =~ s/\n__END__\n.*$/\n/s; |
30
|
|
|
|
|
|
|
|
31
|
7
|
|
|
|
|
88
|
my @data = split /^@@\s+(.+?)\s*\r?\n/m, $content; |
32
|
7
|
|
|
|
|
15
|
shift @data; # trailing whitespaces |
33
|
|
|
|
|
|
|
|
34
|
7
|
|
|
|
|
15
|
my $all = {}; |
35
|
7
|
|
|
|
|
30
|
while (@data) { |
36
|
14
|
|
|
|
|
36
|
my ($name, $content) = splice @data, 0, 2; |
37
|
14
|
|
|
|
|
57
|
$all->{$name} = $content; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
7
|
|
|
|
|
33
|
return $all; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |