SlideShare a Scribd company logo
Better detection of
what modules are used
by some Perl 5 code
Kenichi Ishigaki
@charsbar
London Perl Workshop 2017
Nov 25, 2017
me
• DBD::SQLite
• CPANTS
• PAUSE on Plack/Mojolicious
• JSON
It's annoying if
prereqs are not
correctly declared
CPANTS has two metrics
to warn this issue
• prereq_matches_use
• build_prereq_matches_use
They usually work,
but sometimes don't
# CPANTS mistakenly complains
my $template =<<'END';
package [% NAME %];
use Foo::Bar; # should be ignored
END
# CPANTS doesn't complain but...
use Shiny::New::Loader; # ok
load("Something::Else"); # ignored
Other detectors?
• Perl::PrereqScanner
(which uses PPI)
• Perl::PrereqScanner::Lite
(which uses Compiler::Lexer)
Limitation: Test::Kwalitee
Perl::PrereqScanner::
NotQuiteLite
• (usually) faster than Perl::PrereqScanner
• slower than Perl::PrereqScanner::Lite,
but more stable
Target: lib/Perl/PrereqScanner/NotQuiteLite.pm
Rate P::PS P::PS::NQL M::EU P::PS::L
P::PS 0.999/s -- -87% -95% -97%
P::PS::NQL 7.69/s 670% -- -62% -76%
M::ExtractUse 20.3/s 1932% 164% -- -36%
P::PS::Lite 31.7/s 3073% 312% 56% --
It recognises not
only Moose family
use Moose;
extends 'Foo::Bar'; # requires
with 'Some::Role'; # requires as well
including MooseX::Declare
use MooseX::Declare;
class MyClass extends Foo::Baz with Role
{
...
}
but also other major frameworks
use Catalyst qw/
My::Module
+Fully::Qualified::Plugin::Name
/;
use Mojo::Base 'Mojo::Base';
use Dancer2::Plugin;
extends('Dancer2::Plugin::ParamTypes');
use Plack::Builder;
builder {
enable_if { ... } 'MyMiddleware';
};
and more...
aliased autouse later mixin only
prefork superclass unless
Class::Accessor Class::Autouse
Class::Load Inline Module::Runtime
Syntax::Collector Test::Class::Most
Test::Requires
and more...
App::GHPT::Wrapper::OurMoose App::wmiirc::Plugin
Ark Bot::Backbone::Service Bubblegum::Class
CatalystX::Declare Cogwheel
CPAN::Testers::Backend::Base Data::Object::Class
DBICx::Modeler::Model Digital::Driver Elastic::Doc
Fey::ORM::Table Form::Factory::Processor Jedi::App
Momo Moonshine::Magic Moxie Nile::Base
Parse::FixedRecord Pcore Reaction::Class
Reaction::UI::WidgetClass Squirrel Statocles::Base
TAEB::OO Test::Able Test::Roo Web::Simple XML::Rabbit
It distinguishes requires from
recommends and suggests
use Foo; # requires
require Bar; # requires as well
if (eval "require Baz") { # suggests
require Quux; # recommends
}
It even knows what
"plan skip_all" means
use Test::More;
BEGIN {
plan skip_all => "N/A" if $^O ne 'MSWin32';
}
use Win32; # recommends
It doesn't really
parse Perl but...
• it recognises (long) strings including
here documents
• it accepts utf8 characters as a
subroutine name ( sub λ {...} )
• and new keywords introduced by
Syntax::Feature family ( qs(...) )
CPANTS will eventually
complain if it finds a cheat
q{
use strict;
use warnings;
}
Migration from
Perl::PrereqScanner
my $pps = Perl::PrereqScanner->new;
my $requirements = $pps->scan_file(...);
my $nql = Perl::PrereqScanner::NotQuiteLite->new;
my $c = $nql->scan_file(...);
my $requirements = $c->requires;
# or $c->recommends, $c->suggests
Updating cpanfile
scan-perl-prereqs-nqlite ¥
--save-cpanfile ¥
--exclude-core ¥
--recommends ¥
--suggests ¥
--develop
You might want to move some of the
recommends/suggests to requires.
Test::CPANfile
• tests if all the used modules
are listed in cpanfile
• it's ok if cpanfile lists more
than used
• recognises runtime, test, and
configure requirements
Thank you

More Related Content

PPT
2016年のPerl (Long version)
PDF
Publishing a Perl6 Module
PPT
On UnQLite
PDF
What you need to remember when you upload to CPAN
PPT
typemap in Perl/XS
PDF
How to inspect a RUNNING perl process
PDF
Unit Testing Lots of Perl
PDF
PL/Perl - New Features in PostgreSQL 9.0 201012
2016年のPerl (Long version)
Publishing a Perl6 Module
On UnQLite
What you need to remember when you upload to CPAN
typemap in Perl/XS
How to inspect a RUNNING perl process
Unit Testing Lots of Perl
PL/Perl - New Features in PostgreSQL 9.0 201012

What's hot (20)

PDF
Effective Benchmarks
PPT
Working with databases in Perl
PDF
How to deploy node to production
PDF
Memory Manglement in Raku
PDF
Perl Sucks - and what to do about it
KEY
Yapcasia2011 - Hello Embed Perl
ODP
The why and how of moving to php 5.4
ODP
Nigel hamilton-megameet-2013
PDF
PL/Perl - New Features in PostgreSQL 9.0
PDF
Getting Testy With Perl6
PDF
Zend con 2016 - Asynchronous Prorgamming in PHP
ODP
The why and how of moving to PHP 5.5/5.6
ODP
Caching and tuning fun for high scalability @ FrOSCon 2011
PDF
BSDM with BASH: Command Interpolation
PDF
Keeping objects healthy with Object::Exercise.
PDF
Object Trampoline: Why having not the object you want is what you need.
PDF
Get your teeth into Plack
PDF
The $path to knowledge: What little it take to unit-test Perl.
PDF
Short Introduction To "perl -d"
PDF
I, For One, Welcome Our New Perl6 Overlords
Effective Benchmarks
Working with databases in Perl
How to deploy node to production
Memory Manglement in Raku
Perl Sucks - and what to do about it
Yapcasia2011 - Hello Embed Perl
The why and how of moving to php 5.4
Nigel hamilton-megameet-2013
PL/Perl - New Features in PostgreSQL 9.0
Getting Testy With Perl6
Zend con 2016 - Asynchronous Prorgamming in PHP
The why and how of moving to PHP 5.5/5.6
Caching and tuning fun for high scalability @ FrOSCon 2011
BSDM with BASH: Command Interpolation
Keeping objects healthy with Object::Exercise.
Object Trampoline: Why having not the object you want is what you need.
Get your teeth into Plack
The $path to knowledge: What little it take to unit-test Perl.
Short Introduction To "perl -d"
I, For One, Welcome Our New Perl6 Overlords
Ad

Similar to Better detection of what modules are used by some Perl 5 code (20)

PDF
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
PPTX
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
PDF
Packaging perl (LPW2010)
PDF
12 Step Guide to Lotuscript
PDF
Functional Programming in Clojure
PDF
perlbrew yapcasia 2010
PDF
Speed geeking-lotusscript
PDF
Jest: Frontend Testing richtig gemacht @WebworkerNRW
PDF
Test::Kantan - Perl and Testing
PDF
Das Frontend richtig Testen – mit Jest @Developer Week 2018
PDF
Testing for Ops: Going Beyond the Manifest - PuppetConf 2013
KEY
Rails Hardware (no conclusions!)
PDF
CPAN 模組二三事
PDF
node.js 실무 - node js in practice by Jesang Yoon
PDF
Testcontainers - Geekout EE 2017 presentation
PDF
DevOps &lt;3 node.js
PDF
20140406 loa days-tdd-with_puppet_tutorial
PDF
Low-Maintenance Perl
PDF
Yapc10 Cdt World Domination
PPTX
What static analyzers can do that programmers and testers cannot
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
Packaging perl (LPW2010)
12 Step Guide to Lotuscript
Functional Programming in Clojure
perlbrew yapcasia 2010
Speed geeking-lotusscript
Jest: Frontend Testing richtig gemacht @WebworkerNRW
Test::Kantan - Perl and Testing
Das Frontend richtig Testen – mit Jest @Developer Week 2018
Testing for Ops: Going Beyond the Manifest - PuppetConf 2013
Rails Hardware (no conclusions!)
CPAN 模組二三事
node.js 실무 - node js in practice by Jesang Yoon
Testcontainers - Geekout EE 2017 presentation
DevOps &lt;3 node.js
20140406 loa days-tdd-with_puppet_tutorial
Low-Maintenance Perl
Yapc10 Cdt World Domination
What static analyzers can do that programmers and testers cannot
Ad

More from charsbar (20)

PPT
Common boolean class_for_perl5
PPT
2018年夏のPerl5
PDF
萬國之津梁
PPT
2017年夏のPerl
PPT
2017年春のPerl
PPT
Json(::PP) is a-changing
PPT
JSON, JSON::PP, and more
PPT
perl language update
PPT
CPANの依存モジュールをもう少し正しく検出したい
PDF
2013年のCPANモジュール作成事情
PDF
Analyze CPAN, Analyze Community
PDF
Annual Report 2012
PDF
DBD::SQLite
PDF
CPANTS: Kwalitative website and its tools
PPT
CPANTS 2012
PPT
Revisiting ppm
PDF
Mojolicious::Liteを使ってみよう
PPT
変数、リファレンス
PPT
關於perl的 文件翻譯
PPT
Practical Bug Reporting
Common boolean class_for_perl5
2018年夏のPerl5
萬國之津梁
2017年夏のPerl
2017年春のPerl
Json(::PP) is a-changing
JSON, JSON::PP, and more
perl language update
CPANの依存モジュールをもう少し正しく検出したい
2013年のCPANモジュール作成事情
Analyze CPAN, Analyze Community
Annual Report 2012
DBD::SQLite
CPANTS: Kwalitative website and its tools
CPANTS 2012
Revisiting ppm
Mojolicious::Liteを使ってみよう
変数、リファレンス
關於perl的 文件翻譯
Practical Bug Reporting

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
Teaching material agriculture food technology
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Modernizing your data center with Dell and AMD
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Electronic commerce courselecture one. Pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Understanding_Digital_Forensics_Presentation.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Teaching material agriculture food technology
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Monthly Chronicles - July 2025
Advanced methodologies resolving dimensionality complications for autism neur...
Diabetes mellitus diagnosis method based random forest with bat algorithm
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Reach Out and Touch Someone: Haptics and Empathic Computing
Modernizing your data center with Dell and AMD
Chapter 3 Spatial Domain Image Processing.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto

Better detection of what modules are used by some Perl 5 code

  • 1. Better detection of what modules are used by some Perl 5 code Kenichi Ishigaki @charsbar London Perl Workshop 2017 Nov 25, 2017
  • 2. me • DBD::SQLite • CPANTS • PAUSE on Plack/Mojolicious • JSON
  • 3. It's annoying if prereqs are not correctly declared
  • 4. CPANTS has two metrics to warn this issue • prereq_matches_use • build_prereq_matches_use
  • 5. They usually work, but sometimes don't # CPANTS mistakenly complains my $template =<<'END'; package [% NAME %]; use Foo::Bar; # should be ignored END # CPANTS doesn't complain but... use Shiny::New::Loader; # ok load("Something::Else"); # ignored
  • 6. Other detectors? • Perl::PrereqScanner (which uses PPI) • Perl::PrereqScanner::Lite (which uses Compiler::Lexer) Limitation: Test::Kwalitee
  • 7. Perl::PrereqScanner:: NotQuiteLite • (usually) faster than Perl::PrereqScanner • slower than Perl::PrereqScanner::Lite, but more stable Target: lib/Perl/PrereqScanner/NotQuiteLite.pm Rate P::PS P::PS::NQL M::EU P::PS::L P::PS 0.999/s -- -87% -95% -97% P::PS::NQL 7.69/s 670% -- -62% -76% M::ExtractUse 20.3/s 1932% 164% -- -36% P::PS::Lite 31.7/s 3073% 312% 56% --
  • 8. It recognises not only Moose family use Moose; extends 'Foo::Bar'; # requires with 'Some::Role'; # requires as well
  • 9. including MooseX::Declare use MooseX::Declare; class MyClass extends Foo::Baz with Role { ... }
  • 10. but also other major frameworks use Catalyst qw/ My::Module +Fully::Qualified::Plugin::Name /; use Mojo::Base 'Mojo::Base'; use Dancer2::Plugin; extends('Dancer2::Plugin::ParamTypes'); use Plack::Builder; builder { enable_if { ... } 'MyMiddleware'; };
  • 11. and more... aliased autouse later mixin only prefork superclass unless Class::Accessor Class::Autouse Class::Load Inline Module::Runtime Syntax::Collector Test::Class::Most Test::Requires
  • 12. and more... App::GHPT::Wrapper::OurMoose App::wmiirc::Plugin Ark Bot::Backbone::Service Bubblegum::Class CatalystX::Declare Cogwheel CPAN::Testers::Backend::Base Data::Object::Class DBICx::Modeler::Model Digital::Driver Elastic::Doc Fey::ORM::Table Form::Factory::Processor Jedi::App Momo Moonshine::Magic Moxie Nile::Base Parse::FixedRecord Pcore Reaction::Class Reaction::UI::WidgetClass Squirrel Statocles::Base TAEB::OO Test::Able Test::Roo Web::Simple XML::Rabbit
  • 13. It distinguishes requires from recommends and suggests use Foo; # requires require Bar; # requires as well if (eval "require Baz") { # suggests require Quux; # recommends }
  • 14. It even knows what "plan skip_all" means use Test::More; BEGIN { plan skip_all => "N/A" if $^O ne 'MSWin32'; } use Win32; # recommends
  • 15. It doesn't really parse Perl but... • it recognises (long) strings including here documents • it accepts utf8 characters as a subroutine name ( sub λ {...} ) • and new keywords introduced by Syntax::Feature family ( qs(...) )
  • 16. CPANTS will eventually complain if it finds a cheat q{ use strict; use warnings; }
  • 17. Migration from Perl::PrereqScanner my $pps = Perl::PrereqScanner->new; my $requirements = $pps->scan_file(...); my $nql = Perl::PrereqScanner::NotQuiteLite->new; my $c = $nql->scan_file(...); my $requirements = $c->requires; # or $c->recommends, $c->suggests
  • 18. Updating cpanfile scan-perl-prereqs-nqlite ¥ --save-cpanfile ¥ --exclude-core ¥ --recommends ¥ --suggests ¥ --develop You might want to move some of the recommends/suggests to requires.
  • 19. Test::CPANfile • tests if all the used modules are listed in cpanfile • it's ok if cpanfile lists more than used • recognises runtime, test, and configure requirements