1Perl::PrereqScanner(3)User Contributed Perl DocumentationPerl::PrereqScanner(3)
2
3
4
6 Perl::PrereqScanner - a tool to scan your Perl code for its
7 prerequisites
8
10 version 1.023
11
13 use Perl::PrereqScanner;
14 my $scanner = Perl::PrereqScanner->new;
15 my $prereqs = $scanner->scan_ppi_document( $ppi_doc );
16 my $prereqs = $scanner->scan_file( $file_path );
17 my $prereqs = $scanner->scan_string( $perl_code );
18 my $prereqs = $scanner->scan_module( $module_name );
19
21 The scanner will extract loosely your distribution prerequisites from
22 your files.
23
24 The extraction may not be perfect but tries to do its best. It will
25 currently find the following prereqs:
26
27 · plain lines beginning with "use" or "require" in your perl modules
28 and scripts, including minimum perl version
29
30 · regular inheritance declared with the "base" and "parent" pragmata
31
32 · Moose inheritance declared with the "extends" keyword
33
34 · Moose roles included with the "with" keyword
35
36 · OO namespace aliasing using the "aliased" module
37
38 Scanner Plugins
39 Perl::PrereqScanner works by running a series of scanners over a
40 PPI::Document representing the code to scan. By default the "Perl5",
41 "Moose", "TestMore", "POE", and "Aliased" scanners are run. You can
42 supply your own scanners when constructing your PrereqScanner:
43
44 # Us only the Perl5 scanner:
45 my $scanner = Perl::PrereqScanner->new({ scanners => [ qw(Perl5) ] });
46
47 # Use any stock scanners, plus Example:
48 my $scanner = Perl::PrereqScanner->new({ extra_scanners => [ qw(Example) ] });
49
51 scan_string
52 my $prereqs = $scanner->scan_string( $perl_code );
53
54 Given a string containing Perl source code, this method returns a
55 CPAN::Meta::Requirements object describing the modules it requires.
56
57 This method will throw an exception if PPI fails to parse the code.
58
59 Warning! It isn't entirely clear whether PPI prefers to receive
60 strings as octet strings or character strings. For now, my advice is
61 to pass octet strings.
62
63 scan_file
64 my $prereqs = $scanner->scan_file( $path );
65
66 Given a file path to a Perl document, this method returns a
67 CPAN::Meta::Requirements object describing the modules it requires.
68
69 This method will throw an exception if PPI fails to parse the code.
70
71 scan_ppi_document
72 my $prereqs = $scanner->scan_ppi_document( $ppi_doc );
73
74 Given a PPI::Document, this method returns a CPAN::Meta::Requirements
75 object describing the modules it requires.
76
77 scan_module
78 my $prereqs = $scanner->scan_module( $module_name );
79
80 Given the name of a module, eg 'PPI::Document', this method returns a
81 CPAN::Meta::Requirements object describing the modules it requires.
82
84 scan-perl-prereqs, in this distribution, is a command-line interface to
85 the scanner
86
88 · Jerome Quelin
89
90 · Ricardo Signes <rjbs@cpan.org>
91
93 · bowtie <bowtie@cpan.org>
94
95 · celogeek <me@celogeek.com>
96
97 · Christopher J. Madsen <perl@cjmweb.net>
98
99 · David Golden <dagolden@cpan.org>
100
101 · David Steinbrunner <dsteinbrunner@pobox.com>
102
103 · Ed J <mohawk2@users.noreply.github.com>
104
105 · Florian Ragwitz <rafl@debian.org>
106
107 · Jakob Voss <voss@gbv.de>
108
109 · Jerome Quelin <jquelin@gmail.com>
110
111 · Jérôme Quelin <jquelin@gmail.com>
112
113 · John SJ Anderson <genehack@genehack.org>
114
115 · Karen Etheridge <ether@cpan.org>
116
117 · Mark Gardner <gardnerm@gsicommerce.com>
118
119 · Neil Bowers <neil@bowers.com>
120
121 · Randy Stauner <rwstauner@cpan.org>
122
123 · Tina Mueller <tinita@cpan.org>
124
125 · Vyacheslav Matjukhin <mmcleric@yandex-team.ru>
126
128 This software is copyright (c) 2009 by Jerome Quelin.
129
130 This is free software; you can redistribute it and/or modify it under
131 the same terms as the Perl 5 programming language system itself.
132
133
134
135perl v5.30.1 2020-01-30 Perl::PrereqScanner(3)