snafu has asked for the wisdom of the Perl Monks concerning the following question:

I've rewritten a script that works very similar to pidof for the use as a support script for a set of scripts.

I have written it as a standalone script because that is what it was before. However, I started thinking that it would be really cool to be able to call it as a module from another script as well as being able to use it from command line. The name of the script right now is 'npid'. Now, if npid had a package statement then simply detected its caller() (not sure if I can do that yet...gotta look up the docs on caller()) then I am thinking that this kind of thing is feasable. If the caller is a parent script then it works by returning the data to the caller and the caller prints it. Otherwise, it prints output in another format.

I am thinking that this would be the best way to go about this because if I call npid as a module then I'm not wasting resources on another instance of the interpretter while at the same time I am allowing the user to use this program from CLI without calling the support scripts to use it.

Is there something I am missing? Is this possible? Is it recommended? What are the snags?

_ _ _ _ _ _ _ _ _ _
- Jim
Insert clever comment here...