line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Simple::Filter::Macro; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Set the VERSION. |
4
|
|
|
|
|
|
|
$VERSION = "0.07"; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Load the Perl pragmas. |
7
|
1
|
|
|
1
|
|
70993
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
126
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=pod |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=item Subroutine FILTER() |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
The outer value of $_ is the content from the module. The inner value of |
15
|
|
|
|
|
|
|
$_ is the content from the script. The Perl function caller is used as |
16
|
|
|
|
|
|
|
follows. E.g. one can write my ($package, $filename, $line) = caller($i) |
17
|
|
|
|
|
|
|
where $i is the level of interest. The elements of the array can be reached |
18
|
|
|
|
|
|
|
as it is known by caller(0)[0] which results the package name of level 0. |
19
|
|
|
|
|
|
|
caller(5) returns the data from the module and caller(6) returns the data |
20
|
|
|
|
|
|
|
from the script. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Outer filter starts here. |
25
|
|
|
|
|
|
|
use Filter::Simple::Compile sub { |
26
|
|
|
|
|
|
|
# Remove the module terminator from the module content. |
27
|
0
|
|
|
|
|
|
$_ =~ s/1;\s//g; |
28
|
|
|
|
|
|
|
# Create the modified script content. |
29
|
0
|
|
|
|
|
|
$_ = sprintf( |
30
|
|
|
|
|
|
|
# Create a single-quoted string for output. |
31
|
|
|
|
|
|
|
q( |
32
|
|
|
|
|
|
|
# Inner filter starts here. |
33
|
|
|
|
|
|
|
use Filter::Simple::Compile sub { |
34
|
|
|
|
|
|
|
# Concatenate content from module and script. |
35
|
|
|
|
|
|
|
$_ = join("\n", |
36
|
|
|
|
|
|
|
'# Line %s %s', "%s", '# Line %s %s', |
37
|
|
|
|
|
|
|
$_, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
# Inner filter ends here. |
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
), (caller(5))[2], (caller(5))[1], |
43
|
|
|
|
|
|
|
$_, |
44
|
|
|
|
|
|
|
(caller(6))[2], (caller(6))[1] |
45
|
|
|
|
|
|
|
); |
46
|
1
|
|
|
1
|
|
494
|
}; |
|
1
|
|
|
|
|
6391
|
|
|
1
|
|
|
|
|
10
|
|
47
|
|
|
|
|
|
|
# Outer filter ends here. |
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |