NAME

Liveman::Cpanfile - Perl project dependency analyzer

SYNOPSIS

use Liveman::Cpanfile;

chmod 0755, $_ for qw!scripts/test_script bin/tool!;

$::cpanfile = Liveman::Cpanfile->new;

$::cpanfile->cpanfile # -> << 'END'
requires 'perl', '5.22.0';

on 'develop' => sub {
	requires 'App::cpm';
	requires 'CPAN::Uploader';
	requires 'Data::Printer', '1.000004';
	requires 'Minilla', 'v3.1.19';
	requires 'Liveman', '1.0';
	requires 'Software::License::GPL_3';
	requires 'V';
	requires 'Version::Next';
};

on 'test' => sub {
	requires 'Car::Auto';
	requires 'Carp';
	requires 'Cwd';
	requires 'File::Basename';
	requires 'File::Find';
	requires 'File::Path';
	requires 'File::Slurper';
	requires 'File::Spec';
	requires 'Scalar::Util';
	requires 'Test::More';
	requires 'Turbin';
	requires 'open';
};

requires 'Data::Printer';
requires 'List::Util';
requires 'common::sense';
requires 'strict';
requires 'warnings';
END

DESCRIPTION

Liveman::Cpanfile parses the structure of a Perl project and extracts dependency information from source code, tests, and documentation. The module automatically detects which modules are used and helps keep the cpanfile up to date.

SUBROUTINES

new ()

Constructor.

pkg_from_path ()

Converts a file path to a Perl package name.

Liveman::Cpanfile::pkg_from_path('lib/My/Module.pm') # => My::Module
Liveman::Cpanfile::pkg_from_path('lib/My/App.pm')    # => My::App

sc ()

Returns a list of executable scripts in the scripts/ and bin/ directories.

Scripts/test_script file:

#!/usr/bin/env perl
require Data::Printer;

bin/tool file:

#!/usr/bin/env perl
use List::Util;



[$::cpanfile->sc] # --> [qw!bin/tool scripts/test_script!]

pm ()

Returns a list of Perl modules in the lib/ directory.

File lib/My/Module.pm:

package My::Module;
use strict;
use warnings;
1;

File lib/My/Other.pm:

package My::Other;
use common::sense;
1;



[$::cpanfile->pm]  # --> [qw!lib/My/Module.pm lib/My/Other.pm!]

mod ()

Returns a list of project package names corresponding to the modules in the lib/ directory.

[$::cpanfile->mod]  # --> [qw/My::Module My::Other/]

md ()

Returns a list of Markdown documentation files (*.md) in lib/.

File lib/My/Module.md:

# My::Module

This is a module for experiment with package My::Module.
\```perl
package My {}
package My::Third {}
use My::Other;
use My;
use Turbin;
use Car::Auto;
\```



[$::cpanfile->md]  # --> [qw!lib/My/Module.md!]

md_mod ()

List of packages embedded in *.md.

[$::cpanfile->md_mod]  # --> [qw!My My::Third!]

deps ()

List of dependencies explicitly specified in scripts and modules without project packages.

[$::cpanfile->deps]  # --> [qw!Data::Printer List::Util common::sense strict warnings!]

t_deps ()

List of dependencies from tests except:

1. Dependencies of scripts and modules.
2. Project packages.
3. Packages embedded in *.md.
[$::cpanfile->t_deps]  # --> [qw!Car::Auto Carp Cwd File::Basename File::Find File::Path File::Slurper File::Spec Scalar::Util Test::More Turbin open!]

cpanfile ()

Returns the text cpanfile with dependencies for the project.

AUTHOR

Yaroslav O. Kosmina mailto:dart@cpan.org

LICENSE

GPLv3

COPYRIGHT

The Liveman::Cpanfile module is copyright © 2025 Yaroslav O. Kosmina. Rusland. All rights reserved.