Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I change my utilities.pl to a utilities.pm module?

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();
like image 208
Frew Schmidt Avatar asked Oct 08 '08 20:10

Frew Schmidt


People also ask

Why is my SP bill so high?

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.

How long does it take to open SP Services account?

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.


2 Answers

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.

like image 134
Tanktalus Avatar answered Nov 15 '22 07:11

Tanktalus


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,

like image 37
brian d foy Avatar answered Nov 15 '22 06:11

brian d foy