in reply to Module/script all in one

The usual way to have a module work as a script is to do something like:
if (defined caller) { print "used as a module"; } else { print "used as a script: @ARGV"; main() }
Is there more that you are trying to accomplish than that?