|No such thing as a small change|
Naive monk trying to make distinctions among subs, external calls and code reuseby jjap (Monk)
|on Sep 07, 2011 at 20:54 UTC||Need Help??|
jjap has asked for the
wisdom of the Perl Monks concerning the following question:
I am finally to the point where I have half decent code that I reuse increasingly. In the spirit of avoiding duplication and improving maintainability I found myself putting that in a standalone script. In a nutshell, it is saving specific email attachments to a given path, since I need to get the filenames for further processing, a call from a "master" Perl script via backticks seemed in order.My naive thought is the following: an external script seems less convenient to retrieve results than returning them back from a subroutine via a reference. However if I start pasting my code as a subroutine in a few different scripts, any improvement I make will have to be updated in all of them.
I suspect making my own module/package may be a way to address this but my code is probably not yet generalized enough and frankly, the thought of making my own module is intimidating for a perpetual newbie like me.
Question:Is the road I am taking (i.e. using external calls) a sustainable approach in the midterm or I am missing something completely obvious?As always your guidance will be appreciated.
Update: Thanks to all for your encouragement and relevant links. I guess I must be feeling like my son did when I removed the training wheels from his bike... It's probably time for me to get going and build a first module
Update 2: Thanks again to all the posters below, this is the very very best advice I ever had (and followed!). I worship you!!