Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Defining a module .....

by ColtsFoot (Chaplain)
on May 12, 2001 at 10:52 UTC ( [id://79922]=note: print w/replies, xml ) Need Help??


in reply to Defining a module .....

Try something along the lines of this:-
Create a file say called Utils.pm
Package Utils; @EXPORT = qw(sub1 sub2); sub sub1 { Code for sub1 here return; } sub sub2 { Code for sub2 here return; }
Then when you want to use the module do the following:-
#!/usr/bin/perl -w use strict; BEGIN {push @INC, qq(/path/to/module/Utils);} use Utils;
You can then reference the subroutines as follows:-
&Utils::sub1(); &Utils::sub2();
Hope this makes sence.

Replies are listed 'Best First'.
Re: Re: Defining a module .....
by japhy (Canon) on May 12, 2001 at 18:25 UTC
    Using @EXPORT and @EXPORT_OK (etc.) are only needed and useful if you're also actually exporting symbols, often with Exporter.pm.

    Also, use lib "path" is generally preferred over manually push()ing to @INC.

    japhy -- Perl and Regex Hacker

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2024-04-24 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found