http://www.perlmonks.org?node_id=244164


in reply to Possible to have a module act as a standalone??

You're thinking about the problem wrong. A module isn't anything more than a collection of (possibly) related functions (and maybe some data). Perl doesn't actually have support for "modules", per se. There are packages and there are files. Most of the time, the "One package, one file" rule tends to hold, so those things are often called modules.

What I understand you wanting to do is to have a set of functionality that can return its output in 2 different ways. Ok - have the functions in the module accept a flag that determines what it should do with that data.

Then, you have your CLI thingy do its thing and you have a stand-alone script that does its thing. (The stand-alone script will, most likely, be extremely short, but that's a good thing.)

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.