in reply to Re: Problem with Perl Modules.
in thread Problem with Perl Modules.

Thanks a ton for your help.It works after i declare the variables in our. Right now i am facing another problem; my perl module has functions too, and i want to access these functions from the scripts which uses the perl module.
package Hello; use Exporter; @ISA = ('Exporter'); # create an Exporter object. # Export all variables and functions via EXPORT statement # updated for exporting Setup CLI keys and Variables our($x,$test,$TestCase); @EXPORT = qw($x $test $TestCase ReadConfigFile);
In my perl module i have written the subroutine for ReadConfigFile. I have another perl script which uses this perl module Hello and invokes ReadConfigFile from the script. When i ran my script it gives me
Undefined subroutine &Hello::ReadConfigFile called at C:\Test\Hello.pl + line 30.
I do not know if i am missing out on something. Please help. Thank You

Replies are listed 'Best First'.
Re^3: Problem with Perl Modules.
by sauoq (Abbot) on Oct 26, 2005 at 16:22 UTC

    I think we'll need a little more info before we can help with this. Unless I'm missing something, from what you've told us, it should work. I would first double check the spelling of your "ReadConfigFile" where you define it. You could get this error if your sub is actually typo'd as "ReadConfgiFile" for instance.

    Aside from your error, I do have a couple quick observations...

    • Your comment "create an Exporter object" doesn't describe what's going on in that line. It actually makes your Hello module inherit from Exporter.
    • Your @ISA and @EXPORT variables should also be declared using our.
    • You might want to consider using @EXPORT_OK instead of @EXPORTin order to avoid cluttering your scripts' namespaces by default.

    -sauoq
    "My two cents aren't worth a dime.";