Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Flexibility in Module for Import or Execute

by temporal (Pilgrim)
on Mar 13, 2013 at 15:11 UTC ( [id://1023226]=note: print w/replies, xml ) Need Help??


in reply to Flexibility in Module for Import or Execute

Well, if this is the sort of thing that caller was designed for then I'm happy to continue doing what I'm doing. Just never know when there's some useful-but-hidden little convenience built into Perl so I thought I'd ask. Thanks for the affirmation tobyink.

At least I now have something to call these code monstrosities thanks to dsheroh. Actually, they're not all that bad - I like how brian d foy refers to them as 'doing double duty' as a module and a script; that's how I view them. His method of implementing this functionality is definitely more elegant:

__PACKAGE__->run( @ARGV ) unless caller(); # use the __PACKAGE__ symbol to call the appropriately scoped run()

He then illustrates that double duty these Modulinos are capable of pulling is by allowing submodules to inherit and optionally override the parent subroutines. So if you're into creating object oriented inheritance hierarchy styled code there is definitely some benefit to be had here.

Personally, my design ends up with one 'master' Modulino which is used by some number of other scripts. This master Modulino contains all common code plus some optional initialization routines and shared variables via Exporter. I'll usually run it directly for tasks composed entirely of its subroutines.

Strange things are afoot at the Circle-K.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-19 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found