Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Dual personality: Module and scriptby tachyon (Chancellor) |
on Aug 03, 2004 at 15:07 UTC ( [id://379682]=note: print w/replies, xml ) | Need Help?? |
As pointed out you really don't want to do this, but here is how anyway* ;-) This only works if you use the module not if you require if as when you use a module the modules import() method is called at the start of proceedings. This is not true for require when import is not called.
On the rare occasions I have made a module a stand alone executable (usually for all the wrong laziness reasons) I have just used the presence of values in @ARGV to initiate script like behaviour. Generally you want to pass some data to a script anyway......
* Recall the story about getting enough rope to hang yourself? cheers tachyon
In Section
Seekers of Perl Wisdom
|
|