Rod wrote:

> What is the best way to read a config file for a perl script.  I have
> some very ugly code that can do it, but I would like to find something
> cleaner.
>
> Thanks,
> Rod.

It depends on how the config file is set up.  Asuming that your config
file is a simple name= value per line file, it is very simple:

my $options = {};

open IN, $option_file_name or die "Could not open ini file: $!";
while (defined my $line = IN) {
   next unless $line;
   my ($key, $value) = split /\s*=\s*/, $line;
   $options->{$key} - $value;
}
close IN;

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to