By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,903 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,903 IT Pros & Developers. It's quick & easy.

reading whole section of INI file

P: 72
Hi,
Is there any module that could read the whole section of INI file?

Example INI file:
[A]
AA=1
AB=2
[b]
BA=2
BC=3

whenever i read the [A] i could get all the parameter as well as value inside the section. e.g.
AA=1
AB=2

Thanks.
Jul 7 '08 #1
Share this Question
Share on Google+
2 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
Did you happen to search CPAN and see if any of the modules did what you want? That is the first place we would look and it should be that way for you as well.

You could use a module, or you could set up a test of each line and have a variable (lets say $chunk) equal to the section name (ie: [A]) If the next line matches [?], then its a new section, if not, you can feed the next line into an array with the section name (A) or whatever you wanted to call it.

Either way, its up to you, just providing you another way that you could do it.

You could also have a test to check for lines beginning with a # and to ignore them.

Regards,

Jeff
Jul 7 '08 #2

KevinADC
Expert 2.5K+
P: 4,059
Many module son CPAN. One written by a perl bud of mine:

Config-INI-Simple

Search Config::Ini and you will find many more.
Jul 7 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.