Solved

My first Perl module doesn't work

Posted on 2007-04-01
5
376 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
  • 3
  • 2
5 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 50 total points
Comment Utility
package Utils;

# or

 use Util qw( timestamp );
0
 

Author Comment

by:JLoewner
Comment Utility
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
Comment Utility
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
Comment Utility
your utils module misses to return "true", add a final line:

1;
0
 

Author Comment

by:JLoewner
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now