I’m looking for An easy trick/Way to modify paramter value of a section in INI file in Perl, as you may know, all parameter in INI file have the same name (that’s its big problem), only the section name can make the difference, but I don’t think that it will help in my case:
Section1
param1=s1value1
param2=val1
Section2
param1=s2value2
param2=val2
Section3
param1=s3value3
param2=val3
I want to change value val2 of parameter param2 of Section2 to valN, Any idea, I looked on module on CPAN, but module needs module and so on, I never had it working, I think that there is an easy way hein?
Try using Config::Tiny:
use Config::Tiny; my $filename = "test.ini"; my $config = Config::Tiny->new(); $config = Config::Tiny->read($filename); print "Before:\n"; print $config->write_string(); $config->{Section2}->{param2} = 'valN'; print "After:\n"; print $config->write_string(); $config->write($filename);