line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Filter::PerlTags; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23964
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
54
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
53
|
|
6
|
1
|
|
|
1
|
|
2086
|
use Filter::Util::Call; |
|
1
|
|
|
|
|
26150
|
|
|
1
|
|
|
|
|
552
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Filter::PerlTags - PHP-ish HTML/Perl mixing |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.01 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This module filter source to allow mixing HTML and Perl, a bit like PHP. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Filter::PerlTags; |
29
|
|
|
|
|
|
|
Content-Type: plain/html |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
print "FOO"; |
34
|
|
|
|
|
|
|
my $gmt = gmtime(); |
35
|
|
|
|
|
|
|
?> |
36
|
|
|
|
|
|
|
The time is $gmt. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 AUTHOR |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Jimi Wills, C<< >> |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 BUGS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
45
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
46
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SUPPORT |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
perldoc Filter::PerlTags |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
You can also look for information at: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=over 4 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * CPAN Ratings |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * Search CPAN |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
L |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=back |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Copyright 2013 Jimi Wills. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
89
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
90
|
|
|
|
|
|
|
copy of the full license at: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
95
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
96
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
97
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
100
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
101
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
104
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
107
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
108
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
109
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
110
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
111
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
112
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
113
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
116
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
117
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
118
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
119
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
120
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
121
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
122
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
our $STATE = 'TEXT'; |
129
|
|
|
|
|
|
|
sub import { |
130
|
1
|
|
|
1
|
|
14
|
my ($type) = @_; |
131
|
1
|
|
|
|
|
3
|
my ($ref) = []; |
132
|
1
|
|
|
|
|
4
|
filter_add(bless $ref); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
sub filter { |
135
|
3
|
|
|
3
|
0
|
3837
|
my ($self) = @_; |
136
|
3
|
|
|
|
|
5
|
my ($status); |
137
|
3
|
100
|
|
|
|
25
|
if( ($status = filter_read()) > 0 ){ |
138
|
2
|
50
|
|
|
|
7
|
my $CODE = $STATE eq 'TEXT' ? 'print qq!' : ''; |
139
|
2
|
|
|
|
|
10
|
foreach(split /((?:<\?|\?>).*?)/){ |
140
|
2
|
50
|
|
|
|
10
|
if(/^<\?/){ |
|
|
50
|
|
|
|
|
|
141
|
0
|
|
|
|
|
0
|
s/^<\?//; |
142
|
0
|
|
|
|
|
0
|
$STATE = 'PERL'; |
143
|
0
|
|
|
|
|
0
|
$CODE .= '!;'; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
elsif(/^\?>/) { |
146
|
0
|
|
|
|
|
0
|
s/^\?>//; |
147
|
0
|
|
|
|
|
0
|
$STATE = 'TEXT'; |
148
|
0
|
|
|
|
|
0
|
$CODE .= 'print qq!'; |
149
|
|
|
|
|
|
|
} |
150
|
2
|
50
|
|
|
|
6
|
s/\!/\\!/g if $STATE eq 'TEXT'; |
151
|
2
|
|
|
|
|
7
|
$CODE .= $_; |
152
|
|
|
|
|
|
|
} |
153
|
2
|
50
|
|
|
|
10
|
$_ = $CODE . ($STATE eq 'TEXT' ? '!;' : ''); |
154
|
|
|
|
|
|
|
} |
155
|
3
|
|
|
|
|
1777
|
$status; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; # End of Filter::PerlTags |