in reply to Re: Calling a subroutine located in a module
in thread Calling a subroutine located in a module

I use strict and warnings on both, is there a problem with that? I am not sure what undeclared variable you are talking about? $var1 and $var2 are declared earlier in the script and $openreturn is declared inline.

------------------------------

Module NOTES

use strict;

use warnings;

use Win32::OLE;

use Win32::OLE::Variant;

use Date::Manip;

use base 'Exporter';

use vars qw($VERSION @EXPORT @EXPORT_OK);

($VERSION) = ' $Revision: 0.1 $ ' =~ /\$Revision:\s+(^\s+)/;

@EXPORT = qw( OpenNotes CloseNotes FetchNotesDoc Search FTSearch ); # Exported by Default

@EXPORT_OK = qw(); # Exported if Reference

rest of code

-----------------------------

Test Script test.pl

use strict;

use warnings;

use Win32::OLE;

use Win32::OLE::Variant;

use NotesOLE;

Bunch of variable stuff

my $openreturn = OpenNotes($dbname,$server);

Rest of code.

---------------------------

It is my understanding that if you use base 'Exporter'; you don't have to declare @ISA in vars, I tried both and had no success!

Tried Export(..) with use Module and Export_ok(…) with use Module qw(sub);

Thanks for the response.

</BODY> </HTML>
  • Comment on Re: Re: Calling a subroutine located in a module

Replies are listed 'Best First'.
Re: Re: Re: Calling a subroutine located in a module
by chipmunk (Parson) on Nov 02, 2001 at 08:07 UTC
    From the code you posted, it looks like you may have forgotten the package declaration in your module. You should add a package NotesOLE; at the top of your module.

    Curiously, although the missing package declaration would prevent perl from calling the module's import method, it should also cause all of the module's methods to be declared in package main in the first place. So, there may be something else going on to cause the Undefined subroutine &main::OpenNotes called ... error. Do you have another module which loads NotesOLE before test.pl does?

    Anyway, put in the package declaration and see what happens.

Re (3): Calling a subroutine located in a module
by VSarkiss (Monsignor) on Nov 02, 2001 at 07:19 UTC

    Hmm. Maybe just a copy-and-paste thing, but in the first part you say your module is named "Notes", but in the sample of test.pl it says "use NotesOLE". Check for typos in the package and file names (although strict should have caught things like that). Otherwise I don't see anything obviously wrong with your code.

    HTH

use base qw(Module); (was Re: Re: Re: Calling a subroutine located in a module)
by brother ab (Scribe) on Nov 02, 2001 at 12:35 UTC

    May be it is out of the thread but I must say a word.

    Be carefull with base pragma, it will only require your base modules, not use them! So import subroutines of the base modules will be ignored.

    A spot from documentation:

    ----------- package Baz; use base qw(Foo Bar);
    Roughly similar in effect to
    BEGIN { require Foo; require Bar; push @ISA, qw(Foo Bar); } ----------

    An example:

    ---------- ### File A.pm package A; sub import { warn "A imported"; } ---------- ### File X.pm package X; use base qw(A); sub import { warn "X imported"; } ---------- ### File Y.pm package Y; use A; use base qw(A); sub import { warn "Y imported"; } ----------- ### File Z.pm package Z; use A; @ISA = qw(A); sub import { warn "Z imported"; } ----------

    And now:

    bash$ perl -e 'use X' import X at X.pm line 7. bash$ perl -e 'use Y' import A at A.pm line 5. import Y at Y.pm line 8. bash$ perl -e 'use Z' import A at A.pm line 5. import Z at Z.pm line 9.

    You can see base module A is not imported in the first case.

    -- brother ab