line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::POSIX; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
714
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
917
|
use POSIX (); |
|
1
|
|
|
|
|
7525
|
|
|
1
|
|
|
|
|
27
|
|
7
|
1
|
|
|
1
|
|
8
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
8
|
1
|
|
|
1
|
|
819
|
use Template::Plugin; |
|
1
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
35
|
|
9
|
1
|
|
|
1
|
|
13
|
use base qw( Template::Plugin ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
10
|
1
|
|
|
1
|
|
7
|
use vars qw( $AUTOLOAD $VERSION ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
602
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$Data::Dumper::Indent = 0; |
15
|
|
|
|
|
|
|
*throw = \&Template::Plugin::POSIX::throw; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
5
|
|
|
5
|
1
|
71141
|
my ($class, $context, $params) = @_; |
19
|
5
|
|
|
|
|
63
|
bless { |
20
|
|
|
|
|
|
|
_context => $context, |
21
|
|
|
|
|
|
|
}, $class; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $entered = 0; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub AUTOLOAD { |
27
|
8
|
|
|
8
|
|
314
|
my $self = shift; |
28
|
8
|
|
|
|
|
18
|
my $method = $AUTOLOAD; |
29
|
|
|
|
|
|
|
#warn "$method"; |
30
|
|
|
|
|
|
|
|
31
|
8
|
|
|
|
|
46
|
$method =~ s/.*:://; |
32
|
8
|
50
|
|
|
|
32
|
return if $method eq 'DESTROY'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#warn "\@_ = @_\n"; |
35
|
8
|
50
|
|
|
|
26
|
if ($entered == 1) { |
36
|
0
|
|
|
|
|
0
|
die("$method not found\n"); |
37
|
|
|
|
|
|
|
} |
38
|
8
|
|
|
|
|
15
|
my @args; |
39
|
8
|
|
|
|
|
20
|
foreach my $arg (@_) { |
40
|
10
|
|
|
|
|
77
|
my $code = Data::Dumper->Dump([$arg], ['args']); |
41
|
10
|
|
|
|
|
673
|
$code =~ s/^\s*\$args\s*=\s*(.*);\s*$/$1/s; |
42
|
10
|
|
|
|
|
22
|
$code =~ s/^\[(.*)\]\s*$/$1/s; |
43
|
10
|
|
|
|
|
35
|
push @args, $code; |
44
|
|
|
|
|
|
|
} |
45
|
8
|
|
|
|
|
37
|
my $code = "POSIX::$method(".join(',', @args).")"; |
46
|
|
|
|
|
|
|
#warn "code: $code\n"; |
47
|
8
|
|
|
|
|
15
|
$entered = 1; |
48
|
8
|
|
|
|
|
536
|
my @retval = eval $code; |
49
|
8
|
|
|
|
|
688
|
$entered = 0; |
50
|
8
|
50
|
|
|
|
26
|
if ($@) { |
51
|
0
|
|
|
|
|
0
|
$self->throw("POSIX function error: $@"); |
52
|
|
|
|
|
|
|
} |
53
|
8
|
50
|
|
|
|
27
|
if (!@retval) { return (); } |
|
0
|
|
|
|
|
0
|
|
54
|
8
|
50
|
|
|
|
29
|
if (@retval == 1) { $retval[0] } |
|
8
|
|
|
|
|
80
|
|
55
|
0
|
|
|
|
|
|
else { \@retval }; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub throw { |
59
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
die (Template::Exception->new('Plugin POSIX', join(', ', @_))); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |