learner
learner

Reputation: 375

How to use Config::IniFiles module to read files

I have been using multiple files for reading different types of configurations but I understand that I might be able to use Config::IniFiles modules and use a single file. My files structure is something like below, can someone help me in understanding how to achieve this. I have been using normal open command for different files, so another question is whether that will be directly replaced by this. Please note that I have to loop through each section

NOTE: earlier I had each [DomainCredentials] And [ProviderCredentials] in different files

[DomainCredentials]

DomainName=SERVER
CustomerCOde=CUSTOMER1

[ProviderCredentials]

Class=A
Routine=B 

Upvotes: 0

Views: 324

Answers (1)

ysth
ysth

Reputation: 98508

I'm not sure exactly what you are asking for, but:

use strict;
use warnings;
use Config::Tiny;

my $config = Config::Tiny->new()->read("config.txt");

print $config->{'DomainCredentials'}{'DomainName'}, "\n";

yields:

SERVER

Upvotes: 1

Related Questions