Question

How do I add entries from an INI file to a hashtable?

My INI file would look like this ...

[Channel 0]
Input = 0
Output = 0
CirUpdateRate = 10000 Hz
CirSourceFile = ..\..\MAT\mymodel.mat
CirControlFile = mymodel_0_S1_T4.sim

[Channel 1]
Input = 1
Output = 1
CirUpdateRate = 10000 Hz
CirSourceFile = ..\..\MAT\mymodel.mat
CirControlFile = mymodel_1_S1_T4.sim

How can I insert each variable and value into hash table.

Will I be able to differentiate or access Variable Input under [Channel 0] and Input Under `[Channel 1]?

Was it helpful?

Solution

Adding comment as answer, per request.

You can use Config::INI.

According to the synopsis, you do:

use Config::INI::Reader; 
my $config_hash = Config::INI::Reader->read_file('config.ini');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top