ExtractSource.pm

filter: Statementstmt 100% 18 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 23 / 23 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« ExtractSource/CodeObj.pm ↑ Summary
1 package Filter::ExtractSource;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Filter::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Filter::ExtractSource::CodeObj;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.02';
9 1 our $codeobj = Filter::ExtractSource::CodeObj->new;
10  
11 1 ▶FILTER {
Subroutine __ANON__: called CC=1 SCAR=0.0
12 1 s/^(\s*use .*;)/$1\nuse Filter::ExtractSource;/m;
13 1 $codeobj->merge(split /use Filter::ExtractSource;\n/);
14 1 };
15  
16 =head1 NAME
17  
18 Filter::ExtractSource - captures Perl code after processing by source filters
19  
20 =head1 SYNOPSIS
21  
22 perl -c -MFilter::ExtractSource input.pl >output.pl
23  
24 Where F<input.pl> contains Perl code which uses source filters,
25 F<output.pl> will be the code post filtering as passed to the
26 Perl parser.
27  
28 =head1 DESCRIPTION
29  
30 The concept of source filtering allows developers to alter and
31 extend the Perl language with relative ease. One disadvantage
32 however, is that some language extensions can break tools which
33 attempt to parse Perl code, such as editors which perform syntax
34 highlighting.
35  
36 For example, the code
37  
38 use Filter::Indent::HereDoc;
39 my $hello = <<EOT;
40 Hello, World!
41 EOT
42 print $hello;
43  
44 is perfectly valid, but trying to parse it manually (i.e.
45 without using C<perl>) will fail as the C<EOT> here-document
46 terminator will not be found.
47  
48 After processing by Filter::ExtractSource, the code becomes
49  
50 use Filter::Indent::HereDoc;
51 my $hello = <<EOT;
52 Hello, World!
53 EOT
54 print $hello;
55  
56 which can now be correctly parsed.
57  
58 =head1 DEPENDENCIES
59  
60 Filter::ExtractSource requires the Filter::Simple module to be installed.
61  
62 =head1 BUGS / ISSUES
63  
64 Possibly lots.
65  
66 Filter::ExtractSource has been tested with the Switch.pm and
67 Filter::Indent::HereDoc source filters with good results. However
68 in particular it has not been tested (and is unlikely to work)
69 with any source filters which perform encryption or obfuscation
70 of Perl code.
71  
72 Any BEGIN blocks, CHECK blocks or use statements will be executed at
73 compile-time (i.e. the code will be executed even when the '-c' switch
74 is used). Therefore any data sent to the STDOUT stream by these blocks
75 will be output before the filtered source code, so in the example above
76 the output.pl file may need to be edited. A future release of
77 Filter::ExtractSource will support writing the modified source code
78 to a file instead of STDOUT to fix this problem.
79  
80 Please report any bugs or feature requests to
81 C<bug-filter-extractsource@rt.cpan.org>, or through the web interface at
82 L<http://rt.cpan.org>. I will be notified, and then you'll automatically
83 be notified of progress on your bug as I make changes.
84  
85 =head1 SEE ALSO
86  
87 Filter::ExtractSource homepage - L<http://perl.jonallen.info/projects/filter-extractsource>
88  
89 Filter::Simple - L<http://search.cpan.org/dist/Filter-Simple>
90  
91 perlfilter manpage - L<http://www.perldoc.com/perl5.8.0/pod/perlfilter.html>
92  
93 =head1 AUTHOR
94  
95 Written by Jon Allen (JJ) <jj@jonallen.info> / L<http://perl.jonallen.info>
96  
97 =head1 COPYRIGHT and LICENCE
98  
99 Copyright 2004 Jon Allen (JJ), All Rights Reserved.
100  
101 This program is free software; you can redistribute it and/or modify it
102 under the same terms as Perl itself.
103  
104 =cut
105  
106 1 1; # End of Filter::ExtractSource
« ExtractSource/CodeObj.pm ↑ Summary