In our product we have a big utilities file that we require (with do
) at the beginning of a lot of our files. Is there a reason not to turn this into a module? For example, instead of doing this:
do '../dbi_utilities.pl';
our ($db,$user,$pw,$attr);
my $Data = DBI->connect($db,$user,$pw,$attr) or die "Could not connect to database: $DBI::errstr";
Couldn't I just do this?:
use AppUtil;
my $Data = AppUtil->connect();
If you see a spike in your current bill, this is because of the cumulative under-estimated amounts that have been added to reflect your actual consumption for the past few months.
Do plan to open your SP utilities account in advance though, as it takes approximately two weeks to turn on the supply. To open your SP services account, make sure you prepare the following documents: Proof of occupancy of your home, such as a Tenancy Agreement/property tax slip.
The only reason not to do this is time.
That is, it'll take time to clean up your interface, as well as all calling apps to use the new interface.
What it'll cost you in time now will be more than made up when you start using proper tests ("make test" or "./Build test" or just "prove ...") and be able to check that your changes won't break anything before checking it in. So, by all means, convert. Just be aware that it's not a free gain.
By making your code into a module with proper refactoring, you make it easy to test. I talk about this in my "Scripts as Modules" article for The Perl Journal as well as "How a Script Becomes a Module" on Perlmonks.
Good luck,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With