Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Modules as executable scripts?

by aufflick (Deacon)
on Jun 19, 2007 at 12:33 UTC ( [id://622005]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Modules as executable scripts?
in thread Modules as executable scripts?

good point - completely correct.

taking a look at the -M syntax in perlrun, a cute thing you could do is to implement (or override) import() in your package, and respond to triggers passed in:

package DoIt; sub import { &run if( $_[0] eq 'run' ); }

the following commandline:

perl -MDoIt=run,arg1,arg2

will call the DoIt::run sub with @_ set to qw(run arg1 arg2).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2025-07-11 15:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.