Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Dual personality: Module and script

by dragonchild (Archbishop)
on Aug 03, 2004 at 14:56 UTC ( [id://379677]=note: print w/replies, xml ) Need Help??


in reply to Dual personality: Module and script

It sounds like you're trying to be too clever. Modules are generally meant to be sourced in from other entities, like scripts. I wouldn't have executable modules, personally.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

  • Comment on Re: Dual personality: Module and script

Replies are listed 'Best First'.
Re^2: Dual personality: Module and script
by japhy (Canon) on Aug 03, 2004 at 16:18 UTC
    In the Python world, the sentiment is exactly the opposite. I remember reading in "Programming Python" this common idiom:
    #!/usr/bin/env python # module mymod2.py def cube(n): return n ** 3 # when 'import'ed, __name__ is 'mymod2' # when executed, __name__ is '__main__' if __name__ == '__main__': if cube(15) != 3375: print "Error, cube(15) is not correct"
    _____________________________________________________
    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2024-04-25 03:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found