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


in reply to How a script becomes a module

A long post for a simple thing, maybe, since there is another way to solve this -- and this is what I do.

Always write modules. Your scripts call modules (componentized by black-box purpose -- not for the sake of having components and subcomponents), however trivial, even if they are just a few lines. Reuse and refactoring come like magic if you have a good API ... so plan one from the start, and write your main script as if it was using a completed module -- then finish the functions you used. Refactor as needed.