In perl, how do I use modules created with module-starter in the same directory?

StackOverflow https://stackoverflow.com/questions/4403891

  •  25-09-2019
  •  | 
  •  

Question

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.
Was it helpful?

Solution

Add the directories you want to be included in the Perl Module search using the PERL5LIB environment variable:

export PERL5LIB=/somedir

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top