GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Perl::PrereqScanner::Lite(3) User Contributed Perl Documentation Perl::PrereqScanner::Lite(3)

Perl::PrereqScanner::Lite - Lightweight Prereqs Scanner for Perl

    use Perl::PrereqScanner::Lite;

    my $scanner = Perl::PrereqScanner::Lite->new;
    $scanner->add_extra_scanner('Moose'); # add extra scanner for moose style
    my $modules = $scanner->scan_file('path/to/file');

Perl::PrereqScanner::Lite is the lightweight prereqs scanner for perl. This scanner uses Compiler::Lexer as tokenizer, therefore processing speed is really fast.

Create a scanner instance.

$opt must be hash reference. It accepts following keys of hash:

  • extra_scanners

    It specifies extra scanners. This item must be array reference.

    e.g.

        my $scanner = Perl::PrereqScanner::Lite->new(
            extra_scanners => [qw/Moose Version/]
        );
        

    See also "add_extra_scanner($scanner_name)".

  • no_prereq

    It specifies to use "## no prereq" or not. Please see also "ADDITIONAL NOTATION".

Scan and figure out prereqs which is instance of "CPAN::Meta::Requirements" by file path.

Scan and figure out prereqs which is instance of "CPAN::Meta::Requirements" by source code string written in perl.

e.g.

    open my $fh, '<', __FILE__;
    my $string = do { local $/; <$fh> };
    my $modules = $scanner->scan_string($string);

Scan and figure out prereqs which is instance of "CPAN::Meta::Requirements" by module name.

e.g.

    my $modules = $scanner->scan_module('Perl::PrereqScanner::Lite');

Scan and figure out prereqs which is instance of "CPAN::Meta::Requirements" by tokens of Compiler::Lexer.

e.g.

    open my $fh, '<', __FILE__;
    my $string = do { local $/; <$fh> };
    my $tokens = Compiler::Lexer->new->tokenize($string);
    my $modules = $scanner->scan_tokens($tokens);

Add extra scanner to scan and figure out prereqs. This module loads extra scanner such as "Perl::PrereqScanner::Lite::Scanner::$scanner_name" if specifying scanner name through this method.

If you want to specify an extra scanner from external package without "Perl::PrereqScanner::Lite::" prefix, you can prepend "+" to $scanner_name. Like so "+Your::Awesome::Scanner".

Extra scanners that are default supported are followings;

  • Perl::PrereqScanner::Lite::Scanner::Moose
  • Perl::PrereqScanner::Lite::Scanner::Version

If "no_prereq" is enabled by "new()" (like so: "Perl::PrereqScanner::Lite->new({no_prereq => 1})"), this module recognize "## no prereq" optional comment. The requiring declaration with this comment on the same line will be ignored as prereq.

For example

    use Foo;
    use Bar; ## no prereq

In this case "Foo" is the prereq, however "Bar" is ignored.

                                Rate   Perl::PrereqScanner Perl::PrereqScanner::Lite
    Perl::PrereqScanner       8.57/s                    --                      -97%
    Perl::PrereqScanner::Lite  246/s                 2770%                        --

                                Rate   Perl::PrereqScanner Perl::PrereqScanner::Lite
    Perl::PrereqScanner       9.00/s                    --                      -94%
    Perl::PrereqScanner::Lite  152/s                 1587%                        --

This is a quotation from <https://github.com/moznion/Perl-PrereqScanner-Lite/issues/13>.

Yes, it's true. This design is so ugly and not smart. So I have to redesign and reimplement this module, and I have some plans.

If you have a mind to expand this module by implementing external scanner, please be careful. Every "scan_*" calls must not affect to any others through the singleton of this module (called it $c in <https://github.com/moznion/Perl-PrereqScanner-Lite/blob/c03638b2e2a39d92f4d7df360af5a6be65dc417a/lib/Perl/PrereqScanner/Lite/Scanner/Moose.pm#L8>).

Perl::PrereqScanner, Compiler::Lexer

Copyright (C) moznion.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

moznion <moznion@gmail.com>
2022-04-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.