Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to pass an argument to a Module?

by BillKSmith (Monsignor)
on Sep 09, 2012 at 15:47 UTC ( [id://992595]=note: print w/replies, xml ) Need Help??


in reply to How to pass an argument to a Module?

I would prefer to write an ordinary subroutine to initialize the global variables at run-time. (Same general idea as the OO "new")

Bill

Replies are listed 'Best First'.
Re^2: How to pass an argument to a Module?
by mascip (Pilgrim) on Sep 09, 2012 at 16:18 UTC

    Something like this?

    use Mod; Mod->initialize('argument');
    I'm going to try.

      If you module is a class, you have written a call to a class method. (That is even better than what I had in mind.) If not, the initialize function would have to be written, passed, and called the same way as every other function in the module.

      Bill

        I just tried it on a simple package and it works :o)
        You're right, as it's not a class i'm doing:

        use Mod; Mod::initialize('argument');

        It is more simple than the previous solutions, and does what i need. Thank you !

        It is less 'elegant' though : there is an additional line of code to put in the client code, each time.
        If someone knows how to use IMPORT i'm still interested in learning.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-19 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found