Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: How can I import a function and set a parameter at the same time?

by CountZero (Bishop)
on Apr 12, 2009 at 08:56 UTC ( [id://757081]=note: print w/replies, xml ) Need Help??


in reply to Re: How can I import a function and set a parameter at the same time?
in thread How can I import a function and set a parameter at the same time?

Maybe the function must be run immediately upon importing, before anything else runs, already during the compilation phase?

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

  • Comment on Re^2: How can I import a function and set a parameter at the same time?

Replies are listed 'Best First'.
Re^3: How can I import a function and set a parameter at the same time?
by ikegami (Patriarch) on Apr 12, 2009 at 08:58 UTC
    In that possible but odd case, the following would do:
    use MyModule qw( MyFunction ); BEGIN { MyFunction('HelloWord'); } # Execute as soon as compiled.
Re^3: How can I import a function and set a parameter at the same time?
by jacques (Priest) on Apr 12, 2009 at 18:55 UTC
    You are on the right track. I want it to work like fatalsToBrowser which also captures compilation errors. Unfortunately, that subroutine doesn't accept arguments (you are not suppose to call it yourself), but I want the same convenience to turn it on or off with a single comment. For example:
    # On use CGI::Carp qw(fatalsToBrowser); # Off # use CGI::Carp qw(fatalsToBrowser);
    I think the solution lies in creating my own custom import sub. I realized this right after posting. Thanks everyone for the thoughts!!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-18 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found