在 perl 中,如何在同一目录中使用使用 module-starter 创建的模块?
我有一堆脚本,我想将它们重构为模块。这是我第一次做这样的事情。我在网上阅读,Module::Starter 似乎是创建新模块的首选方法之一。但是,在开发过程中,我应该如何使用其他不相关脚本中的模块呢?我不想每次修改它时都构建/安装每个模块。此外,我应该如何在同一目录中分发带有模块的脚本? (即,我想在同一个 tar 球中分发带有 Foo::Bar 和 Foo::Baz 的应用程序 script.pl,并且我希望“perl script.pl”能够正常工作,尤其是在草莓上)。有什么提示吗?
> module-starter --module=Foo::Bar
Created Foo-Bar
Created Foo-Bar/lib/Foo
Created Foo-Bar/lib/Foo/Bar.pm
Created Foo-Bar/t
Created Foo-Bar/t/pod-coverage.t
Created Foo-Bar/t/pod.t
Created Foo-Bar/t/manifest.t
Created Foo-Bar/t/boilerplate.t
Created Foo-Bar/t/00-load.t
Created Foo-Bar/ignore.txt
Created Foo-Bar/Makefile.PL
Created Foo-Bar/Changes
Created Foo-Bar/README
Created Foo-Bar/MANIFEST
Created starter directories and files
> perl -MFoo::Bar -w -e ''
Can't locate Foo/Bar.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .).
BEGIN failed--compilation aborted.
I have a bunch of scripts which I want to refactor into modules. This is the first time I'm doing something like this. I read online and Module::Starter seems to be one of the preferred ways of creating new modules. But how should I, during development, use the modules from other unrelated scripts? I don't want to build/install every module every time I modify it. Furthermore, how should I distribute scripts with modules in the same directory? (Ie, I want to distribute an application script.pl with Foo::Bar and Foo::Baz in the same tar ball, and I want 'perl script.pl' to just-work, especially on strawberry). Any hints?
> module-starter --module=Foo::Bar
Created Foo-Bar
Created Foo-Bar/lib/Foo
Created Foo-Bar/lib/Foo/Bar.pm
Created Foo-Bar/t
Created Foo-Bar/t/pod-coverage.t
Created Foo-Bar/t/pod.t
Created Foo-Bar/t/manifest.t
Created Foo-Bar/t/boilerplate.t
Created Foo-Bar/t/00-load.t
Created Foo-Bar/ignore.txt
Created Foo-Bar/Makefile.PL
Created Foo-Bar/Changes
Created Foo-Bar/README
Created Foo-Bar/MANIFEST
Created starter directories and files
> perl -MFoo::Bar -w -e ''
Can't locate Foo/Bar.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .).
BEGIN failed--compilation aborted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 PERL5LIB 环境变量添加要包含在 Perl 模块搜索中的目录:
Add the directories you want to be included in the Perl Module search using the PERL5LIB environment variable: