line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::ToDemo; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
957
|
$Pod::ToDemo::VERSION = '1.20110709'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: writes a demo program from a tutorial POD |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
136
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import |
11
|
|
|
|
|
|
|
{ |
12
|
4
|
|
|
4
|
|
8261
|
my ($self, $action) = @_; |
13
|
4
|
100
|
|
|
|
21
|
return unless $action; |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
14
|
my $call_package = caller(); |
16
|
3
|
|
|
|
|
45
|
my @command = caller( 3 ); |
17
|
|
|
|
|
|
|
|
18
|
3
|
100
|
66
|
|
|
82
|
return if @command and $command[1] ne '-e'; |
19
|
|
|
|
|
|
|
|
20
|
2
|
100
|
|
|
|
15
|
my $import_sub = defined &$action ? |
21
|
|
|
|
|
|
|
$action : $self->import_default( $action ); |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
248
|
|
24
|
2
|
|
|
|
|
3
|
*{ $call_package . '::' . 'import' } = $import_sub; |
|
2
|
|
|
|
|
13
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub import_default |
28
|
|
|
|
|
|
|
{ |
29
|
1
|
|
|
1
|
1
|
2
|
my ($self, $text) = @_; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return sub |
32
|
|
|
|
|
|
|
{ |
33
|
1
|
|
|
1
|
|
6
|
my ($self, $filename) = @_; |
34
|
1
|
|
|
|
|
4
|
Pod::ToDemo::write_demo( |
35
|
|
|
|
|
|
|
$filename, "#!$^X\n\nuse strict;\nuse warnings;\n\n$text" |
36
|
|
|
|
|
|
|
); |
37
|
1
|
|
|
|
|
5
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub write_demo |
41
|
|
|
|
|
|
|
{ |
42
|
4
|
|
|
4
|
1
|
1732
|
my ($filename, $demo) = @_; |
43
|
4
|
|
|
|
|
12
|
my $caller_package = (caller())[0]; |
44
|
|
|
|
|
|
|
|
45
|
4
|
100
|
|
|
|
116
|
die "Usage:\n\t$0 $caller_package \n" unless $filename; |
46
|
3
|
100
|
|
|
|
44
|
die "Cowardly refusing to overwrite '$filename'\n" if -e $filename; |
47
|
|
|
|
|
|
|
|
48
|
2
|
50
|
|
|
|
204
|
open( my $out, '>', $filename ) or die "Cannot write '$filename': $!\n"; |
49
|
2
|
|
|
|
|
1277
|
print $out $demo; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |