?
Solved

My first Perl module doesn't work

Posted on 2007-04-01
5
Medium Priority
?
383 Views
Last Modified: 2008-02-01
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.
0
Comment
Question by:JLoewner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 150 total points
ID: 18832294
package Utils;

# or

 use Util qw( timestamp );
0
 

Author Comment

by:JLoewner
ID: 18833251
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
0
 

Author Comment

by:JLoewner
ID: 18833361
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.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18834801
your utils module misses to return "true", add a final line:

1;
0
 

Author Comment

by:JLoewner
ID: 18834855
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!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Starting up a Project

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question