2014-01-17 4 views
3

나는 node.js와 함께 package.json, Ruby는 Gemfile, Objective-C는 Podfile 등으로 익숙하다.펄 프로젝트에 필요한 패키지와 버전 정의하기

Perl에 해당하는 파일은 무엇이며 사용 된 구문은 무엇입니까?

나는 cpanm을 사용하여 몇 개의 패키지를 설치했으며 패키지 이름과 버전을 팀 구성원이 실행할 수있는 단일 파일로 저장하려고합니다.

+2

[cpanfile] (http://search.cpan.org/~miyagawa/Module-CPANfile-1.0002/lib/cpanfile .pod), http://stackoverflow.com/q/17696492/223226 –

답변

2

간단한 사용 사례 인 경우 cpanfile을 작성하는 것이 좋습니다. 샘플 파일은 다음과 같을 수 있습니다.

requires 'Marpa::R2', '2.078'; 
requires 'String::Escape', '2010.002'; 
requires 'Moo', '1.003001'; 
requires 'Eval::Closure', '0.11'; 

on test => sub { 
    requires 'Test::More', '0.98'; 
}; 

즉 실제로는 데이터 형식이 아닌 Perl 스크립트입니다. 그런 다음 종속성을 설치할 수 있습니다.

$ cd /path/to/your/module 
$ cpanm --installdeps . 

이렇게하면 모듈이 설치되지 않습니다! 그러나 모든 종속성이 충족되어 있는지 확인하여 다음 작업을 수행 할 수 있습니다.

use lib '/path/to/your-module/lib'; # add the location as a module search root 
use Your::Module; # works! yay 

일반적으로 충분합니다. 당신은 다른 사람이 땜질하기를 원하는 자식 저장소 (git repository)를 위해. 당신이 분산하고 쉽게 설치할 수있는 타르볼을 만들려면


, 내가 권하고 싶습니다 Dist::Zilla (이 CPAN 자료에 맞 비록). 그런 다음

name = Your-Module 
version = 1.2.3 
author = Your Self <[email protected]> 
license = GPL_3 
copyright_holder = Your Self 

[@Basic] 

[Prereqs] 
Marpa::R2  = 2.078 
String::Escape = 2010.002 
Moo    = 1.003001 
Eval::Closure = 0.11 

[Prereqs/TestRequires] 
Test::More  = 0.98 

: 대신 cpanfile의 우리가 dist.ini를 사용

$ dzil test # sanity checks, and runs your tests 
$ dzil build # creates a tarball 

DIST : 질라 모듈을 설치하는 데 필요한되는 Makefile.PL 및 기타 인프라를 만드는 처리합니다.

그런 다음 타르볼을 배포하고 cpanm Your-Module-1.2.3.tar.gz처럼 설치할 수 있습니다. 종속성이 해결되고 패키지가 영구 위치에 복사되므로 위치를 지정하지 않고도 모든 스크립트에서 use Your::Module이 가능합니다. 펄 모듈의 표준 디렉토리 레이아웃을 준수해야합니다

참고 :

./ 
    lib/ 
    Your/ 
     Module.pm # package Your::Module 
     Module/ 
     Helper.pm # package Your::Module::Helper 
    t/ # tests to verify the module works on the target syste, 
    foo.t 
    bar.t 
    xt/ # optional: Author tests that are not run on installation 
    baz.t 
    bin/ # optional: scripts that will later end up in the target system's $PATH 
    command-line-tool 
+1

나는 보통 ['[AutoPrereqs]'] (http://p3rl.org/Dist::Zilla::Plugin::AutoPrereqs) 대신에 ['[Prereqs]'] (http://p3rl.org/Dist::Zilla::Plugin::Prereqs). –

-1

Makefile.PL (보통 다른 파일들과 함께, 펄은 당신이 언급 한 다른 언어들보다 더 오래 꾸러미를 가지고 있으며 약간의 불임을 겪고 있습니다).

Module Starter은 패키지 작성을 시작하는 현명한 방법입니다. 책은 getting started입니다.

관련 문제