while do-able, doing so makes life much more complicated for your users.
you want a module that can be run as a script, but the search paths for scripts (OS determined) and modules (Perl determined) are different. if it's in a place where it could be run as a script, then it can't be loaded as a module w/o hackery. ditto for the reverse, if it's in a place where it could be loaded as a module (use Foo;) then it's not in a place where it could be called as a script.
create a module Foo.pm in the usual place. write a small foo wrapper script to put in the OS's search path.
this doesn't stop you from placing the script code in the module. infact it's probably wise to do so.
# Foo.pm package Foo; ... sub foo { for (@_) { Foo->new($_)->blah->print; } } 1; #!/usr/bin/perl # Foo wrapper script use Foo; Foo::foo(@ARGV);
i can't see a way around having two files when you want to be able to do 'foo "blah"' from the command line and 'use Foo;' in perl.
In reply to Re: Possible to have a module act as a standalone??
by zengargoyle
in thread Possible to have a module act as a standalone??
by snafu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |