Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of johanvdb (1872)

Wednesday October 02, 2002
04:24 AM

About configurating modules ...

[ #8126 ]
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