Module::CPANfile::Writer - Module for modifying the cpanfile
use Module::CPANfile::Writer; my $writer = Module::CPANfile::Writer->new('cpanfile'); $writer->add_prereq('Moo', '2.003004'); $writer->add_prereq('Test2::Suite', undef, relationship => 'recommends'); $writer->save('cpanfile');
Module::CPANfile::Writer lets you modify the version of modules in the existing cpanfile.
cpanfile is very flexible because it is written in Perl by using DSL, you can write comments and even code. Therefore, modifying the cpanfile is not easy and you have to understand Perl code.
The idea of modifying the cpanfile was inspired by App::CpanfileSliptop. This module uses PPI to parse and analyze the cpanfile as Perl code. But PPI depends XS modules such as Clone and Params::Util, so these modules are annoying to fatpack in one pure-perl script.
- $writer = Module::CPANfile::Writer->new($file)
- $writer = Module::CPANfile::Writer->new(\$src)
This will create a new instance of Module::CPANfile::Writer.
It takes the filename or the content of cpanfile as scalarref.
This will returns the content of modified cpanfile.
- $writer->add_prereq($module, [$version, relationship => $relationship)
Modify the version of specified
You can also pass
$versionto 0 or undef, this will remove the version requirement of
Write the content of modified cpanfile to the
Copyright (C) Takumi Akiyama.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Takumi Akiyama <email@example.com>