Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^2: Simple Module Tutorial

by toolic (Bishop)
on Mar 07, 2011 at 15:25 UTC ( #891832=note: print w/replies, xml ) Need Help??

in reply to Re: Simple Module Tutorial
in thread Simple Module Tutorial

"Test" is a poor choice of a module name because there is a Core module of the same name (Test) which is part of the standard Perl distribution. Furthermore, since you placed your .pm file under a directory named "Test", you would need to type use Test::Test;. I strongly recommend you change the name of your module to something more unique in order to avoid this naming collision.

Replies are listed 'Best First'.
Re^3: Simple Module Tutorial
by Anonymous Monk on Mar 07, 2011 at 16:11 UTC

    Dear toolic,

    Thank you for your reply. I now have changed all instances of "Test" with "MyModule" and also changed the name of the module. is now situated on


    and I use

    use lib '/storage/username/local/perl/site/lib'; with the second case (as per the example):
    # case 2 use MyModule; print func1(@list),"\n"; print MyModule::func2(@list),"\n";

    but I still get the same error: Undefined subroutine &main::func1 called at MyScript line 15.

    Just to make sure I copied the module exactly from the example but to no avail. Interestingly, when I comment out the print func1 part, the line after that produces correct output. I hope that someone could point out to me where I am at fault.

    Best regards,


      You didn't copy the example exactly!

      You copied case 1. Your code does not export any functions, just as the Tutorial says it won't. You need to export the functions before you try to use them that way:

      use MyModule qw(&func1);
Re^3: Simple Module Tutorial
by Anonymous Monk on Mar 07, 2011 at 16:58 UTC

    Hi toolic

    For some reason I can't reply to your latest post but thanks a mil! I did copy the module exactly but not the script. Somehow I mixed up case 1 and case 2. I expected case 1 not to work but case 2 but instead of coding

    use MyModule qw(&func1);

    I simply used

    use MyModule;

    Thanks a lot for pointing it out, it seems to work now. I have learned quite a bit.

    Best regards,


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://891832]
[Discipulus]: shmem the first time I was in germany I was so smart to learn by heart the address of the hostel: Einbahnstraße..
[Discipulus]: james28909 you are welcome
james28909 doesnt drink much alcohol
james28909 does enjoy blazing up though
james28909 also walks around hunting for his cell phone while using its flashlight function

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2018-05-20 16:14 GMT
Find Nodes?
    Voting Booth?