Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Simple Module Tutorial

by Anonymous Monk
on Mar 07, 2011 at 16:11 UTC ( #891843=note: print w/ replies, xml ) Need Help??


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

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. MyModule.pm is now situated on

/storage/username/local/perl/site/lib

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,

Gideon


Comment on Re^3: Simple Module Tutorial
Select or Download Code
Re^4: Simple Module Tutorial
by toolic (Chancellor) on Mar 07, 2011 at 16:34 UTC
    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);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://891843]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-12-29 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (184 votes), past polls