Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

My first Perl module doesn't work

Posted on 2007-04-01
5
Medium Priority
?
384 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

610 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