Fellow Monks,
I have an .ini file that I'd like to put into a hash, it's of the format:
$xmldir="c:\test"
$cvs="d:\test"
%name=lancelot
etc.
It's a bit of a mess, with some lines using quotes and others not. I wrote a short script that seems to work fine:
open FILE, "anyfile.ini"||die "file open failed\n";
my %inihash=();
while (my $line = <FILE>) {
$line =~ tr/"//d;
(my $key, my $value)=split(/=/,$line);
$inihash{$key}=$value;
};
print "$inihash{'$xmldir'}";
print "$inihash{'$cvs'}";
print "$inihash{'%name'}";
But, there must be a more efficient way of doing this, possibly using Config::IniFiles or some other code improvements. I'm open to any ideas that my fellow monks could suggest (comments, criticisms, etc.)
Thanks in advance.