Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: Modules as executable scripts?

by friedo (Prior)
on Jun 15, 2007 at 06:25 UTC ( #621406=note: print w/replies, xml ) Need Help??

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

perl -MYour::Package -e run

Note that this only works if Your::Package exports run by default, since code executed via -e runs in the main package.

Replies are listed 'Best First'.
Re^3: Modules as executable scripts?
by aufflick (Deacon) on Jun 19, 2007 at 12:33 UTC
    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?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2022-01-21 21:52 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (59 votes). Check out past polls.