Sudarshan Raghavan wrote:
> [EMAIL PROTECTED] wrote:
>
> > It is my first time writing a module. After executing a script that
> > requires my module, I got an error "blabla not found in /usr/lib/perl
> > etc.".
> > So I moved my module to /usr/lib/perl/ and it work o.k.
> > Recently I read somewhere that, instead of always moving  my modules to
> > /usr/lib/perl/, I could place them anywhere in my program directory and
> > indicate the location in my scripts e.g.
> > #!/usr/bin/perl -w
> > push(@INC, "MyLibDir");
> > require mymodule.pm;
> > ###############################
> > But one thing that am not sure of is: Do I need "push(@INC,
> > "MyLibDir")";in all my scripts or is it enough only to indicate only
> > once?
> >
>
> The push (...) way is an option but I wouldn't recommend it. push will
> add your module dir to the end of the @INC array, if accidentally there
> was another module of the same name yours will not get loaded. The right
> way to do this is
> use lib qw(your_module_dir);
>
> This will add your dir at the beginning of the @INC array and will also
> handle duplicates
> perldoc lib
>
> I guess you will have to do this in all your scripts

... but obviously only those that do a 'use', a 'require' or a 'do' on
modules in "MyLibDir".

It's also worth pointing out that @INC generally has the current directory
'.' as its last
element, so that if Perl can't find the module file in all the standard
places it also checks
the directory that the program itself is in. This can be useful for a quick
fix or for
preliminary testing without affecting the public library directories.

HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to