And, it's worth mentioning a couple of things.
If your module and the script that's using it are in the same directory, you don't need use lib. However, if you run it like this:
C:\> perl C:\test\testbvt\hello.pl
Perl sees C:\ as the current directory, and so can't find the modules. If you cd to C:\test\testbvt first, it should work. If this is the type of situation you have, you are wiser not to use lib, but to specify:
C:\> perl -IC:\test\testbvt C:\test\testbvt\hello.pl
The I option specifies a dir to add to @INC for that run only.
On the other hand, if you have the following files:
C:\test\hello.pl
C:\test\Lib\Hello.pm
You might want to change your package name to Lib::Hello instead of just Hello. Definitely read the docs for lib and perlmod, which cover how modules are located and how @INC works.
Two quick last points. First, perl modules are not 'scripts': therefore you don't need (and probably shouldn't use) the #!/usr/bin/perl line in them. That line is a UNIX thing that lets the shell know to invoke the Perl interpreter for the file in question. By the time you import a module, the interpreter is working (not the shell).
Second, make a habit of including use strict; use warnings; at the top of scripts and modules until you understand when they can/should be turned off. If you get warnings you don't understand, add use diagnostics; as well, which give a more verbose explanation.
|