line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#============================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Template::Plugin::Procedural |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# DESCRIPTION |
6
|
|
|
|
|
|
|
# A Template Plugin to provide a Template Interface to Data::Dumper |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# AUTHOR |
9
|
|
|
|
|
|
|
# Mark Fowler |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# COPYRIGHT |
12
|
|
|
|
|
|
|
# Copyright (C) 2002 Mark Fowler. All Rights Reserved |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# This module is free software; you can redistribute it and/or |
15
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
#============================================================================== |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Template::Plugin::Procedural; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
294
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
22
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
23
|
1
|
|
|
1
|
|
3
|
use base 'Template::Plugin'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
364
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = 1.17; |
26
|
|
|
|
|
|
|
our $DEBUG = 0 unless defined $DEBUG; |
27
|
|
|
|
|
|
|
our $AUTOLOAD; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
30
|
|
|
|
|
|
|
# load |
31
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub load { |
34
|
2
|
|
|
2
|
1
|
2
|
my ($class, $context) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# create a proxy namespace that will be used for objects |
37
|
2
|
|
|
|
|
4
|
my $proxy = "Template::Plugin::" . $class; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# okay, in our proxy create the autoload routine that will |
40
|
|
|
|
|
|
|
# call the right method in the real class |
41
|
1
|
|
|
1
|
|
4
|
no strict "refs"; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
200
|
|
42
|
2
|
50
|
|
|
|
2
|
unless( defined( *{ $proxy . "::AUTOLOAD" } ) ) { |
|
2
|
|
|
|
|
8
|
|
43
|
2
|
|
|
|
|
27
|
*{ $proxy . "::AUTOLOAD" } = sub { |
44
|
|
|
|
|
|
|
# work out what the method is called |
45
|
7
|
|
|
7
|
|
65
|
$AUTOLOAD =~ s!^.*::!!; |
46
|
|
|
|
|
|
|
|
47
|
7
|
50
|
|
|
|
25
|
print STDERR "Calling '$AUTOLOAD' in '$class'\n" |
48
|
|
|
|
|
|
|
if $DEBUG; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# look up the sub for that method (but in a OO way) |
51
|
7
|
|
|
|
|
28
|
my $uboat = $class->can($AUTOLOAD); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# if it existed call it as a subroutine, not as a method |
54
|
7
|
100
|
|
|
|
11
|
if ($uboat) { |
55
|
5
|
|
|
|
|
2
|
shift @_; |
56
|
5
|
|
|
|
|
9
|
return $uboat->(@_); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
2
|
50
|
|
|
|
4
|
print STDERR "Eeek, no such method '$AUTOLOAD'\n" |
60
|
|
|
|
|
|
|
if $DEBUG; |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
7
|
return ""; |
63
|
2
|
|
|
|
|
6
|
}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# create a simple new method that simply returns a blessed |
67
|
|
|
|
|
|
|
# scalar as the object. |
68
|
2
|
50
|
|
|
|
3
|
unless( defined( *{ $proxy . "::new" } ) ) { |
|
2
|
|
|
|
|
7
|
|
69
|
2
|
|
|
|
|
5
|
*{ $proxy . "::new" } = sub { |
70
|
2
|
|
|
2
|
|
2
|
my $this; |
71
|
2
|
|
|
|
|
8
|
return bless \$this, $_[0]; |
72
|
2
|
|
|
|
|
5
|
}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
2
|
|
|
|
|
5
|
return $proxy; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |