Solved

My first Perl module doesn't work

Posted on 2007-04-01
5
380 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 50 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

732 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