http://qs321.pair.com?node_id=622005


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).