Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Possible to have a module act as a standalone??

by perrin (Chancellor)
on Mar 18, 2003 at 22:44 UTC ( #244173=note: print w/replies, xml ) Need Help??

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

Separate your data from its presentation. Put the code that does the actual program logic in a module, and then call it from either a standalone script or a CLI script. Make it simply return data and not print anything. Then the standalone script and CLI script get to decide how they want to display the data that is being returned.
  • Comment on Re: Possible to have a module act as a standalone??

Replies are listed 'Best First'.
Re: Possible to have a module act as a standalone??
by dmmiller2k (Chaplain) on Mar 19, 2003 at 06:44 UTC

    Bravo. That is precisely what I think dragonchild was trying to suggest without spelling it out explicitly (as in: "if I think it through fer ye, ya won't learn nuthin'").

    It's how I interpreted the original question as I read it, as well.

    There seems to sometimes be a tendency amongst (us) developers/programmers/technocrats to overcomplicate, at least in my case, in the sense that the obvious can be overlooked in favor of a literal interpretation that misses the point. Being guilty of the same, however, does not preclude being able to detect when it happens to someone else. Nay, it can make it stand out sometimes (we must all remember "it takes one to know one" from childhood).

    It seems to me that asking some questions implies a need for understanding of the realm that the answers might take, and lacking that understanding, the question may understandably suggest to an otherwise knowledgable individual, an unintended specificity that is not actually there.

    In this case, the original poster snafu seems (to me) to be asking how to write a block of code in such a way that it may be used as a module (e.g., using user by a larger program and also standalone. The answer as I would deliver it is that it should be written as a module, with an entry point (sub) written to accept what might be command-line arguments. Then, a trivial command-line script (i.e., shell) could be written in several lines which simply loads the module and passes its comand-line arguments directly into the sub, without manipulating them.

    My .02 ...


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2019-07-20 07:59 GMT
Find Nodes?
    Voting Booth?

    No recent polls found