About configurating modules ...

johanvdb on 2002-10-02T09:24:59

Some thought about the configuration of GSM::SMS ...

I got a very good tip, yesterday, from barries, author of XML::SAX::Machines on how to be able to do module configuration.

On a linux box, most config files are /etc, and this is just fine. When using Perl, you can argue to put a config in /etc or to use a module (.pm file) to store configuration stuff.

Now I settled on using a module for storing the configuration stuff. So now I'm able to do:
perl -MGSM::SMS::Config -esetup
and the command line based configuration manager will pop up. The same code gets invoked when running:
perl Makefile.PL

In a nutshell it works like this:

use Config;
use File::Spec;

...
my $file = File::Spec->catfile( $Config{'installsitelib'}, "GSM", "SMS", "Config", "Default.pm"
);
open F, ">$file";
print F $config;
close F;

The clever thing is using Config to find the install dir and File::Spec to have a platform independent way of creating a path to the pm file.

Ah yes, I don not use Term::ReadLine anymore, but reverted to ExtUtils::MakeMaker::prompt.

Johan