Link to home
Start Free TrialLog in
Avatar of JLoewner
JLoewner

asked on

My first Perl module doesn't work

I want to test my first Perl module and need some help.
I have a module:
  package Util;
  require Exporter;
  our @ISA        = qw(Exporter);
  #our @Export     = qw(timestamp);
  our @Export_OK  = qw( &timestamp );
  our $VERSION    = 1.00;
sub timestamp {...}

The Perl program:
 use Utils qw( timestamp );
 my $x2 = timestamp();

 The error is:
Undefined subroutine &main::timestamp called at K:\SOURCE\Perl\Utils\Test.pl line 8.
Changing to my $x2 = Utils::timestamp():
Undefined subroutine &Utils::timestamp called at K:\SOURCE\Perl\Utils\Test.pl line 8.

The program is at x:\perl\src
The module is at y:\perl\_mymodules
Perl install is on e:\perl
Perl is ActiveState

Anybody an idea how to resolve the problem?
I wouldn't like to install the module while testing it.
(but nethertheless: Howto do that?)

BTW: @INC has added the path to the module dir. Also the PERL5LIB environment var.
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JLoewner
JLoewner

ASKER

Thats it.

Ashes on my head.

Maybe you could give me a hint to the then following problem:
use Utils qw( timestamp ); # shows following error:
cant continue after import errors BEGIN failed
Got it all.
@Export     = qw(timestamp);
@Export_OK  = qw( &timestamp );
Export.. has all to be uppercase.

That resolved the err:
  cant continue after import errors BEGIN failed

Thanks folks.
your utils module misses to return "true", add a final line:

1;
To ahoffman:
the "1;" is there.
I published only the short form with in my eyes relevant parts.

But as I said: Anything works fine now.
Thank You!