Hi,
I have the need to compute a configuration file in order to perform certain tasks. The config file has different chapters.
This is - how i started - but I am kind of stock. I thought to read the config file and store all different chapters in separate array - so I can compute them after - as needed.
But how .. ? Any help appretiated.
Cheers - Dietmar
#!/usr/bin/perl
my $count="0";
$conffile="/tmp/config.cfg";
my (@chapter,@nodegroupdef,@customergroup,@linux,@windows);
open(CONF,"<$conffile") or die "Cannot open $conffile\n";
while (<CONF>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
if ( "$_" eq "^[NodegroupDefault" ) {
......
}
The look of the config file:
###Config File
[NodeGroupDefault]
1HOURHC
PRODUCTION
#
#
[CUSTOMER_GROUP]
customer_a=group_a
customer_b=group_b
customer_c=group_c
#
#
[Assignment_Linux]
Linux_a
Linux_b
#
[Assignment_Windows]
Windows_A
Windows_B
I have the need to compute a configuration file in order to perform certain tasks. The config file has different chapters.
This is - how i started - but I am kind of stock. I thought to read the config file and store all different chapters in separate array - so I can compute them after - as needed.
But how .. ? Any help appretiated.
Cheers - Dietmar
#!/usr/bin/perl
my $count="0";
$conffile="/tmp/config.cfg";
my (@chapter,@nodegroupdef,@customergroup,@linux,@windows);
open(CONF,"<$conffile") or die "Cannot open $conffile\n";
while (<CONF>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
if ( "$_" eq "^[NodegroupDefault" ) {
......
}
The look of the config file:
###Config File
[NodeGroupDefault]
1HOURHC
PRODUCTION
#
#
[CUSTOMER_GROUP]
customer_a=group_a
customer_b=group_b
customer_c=group_c
#
#
[Assignment_Linux]
Linux_a
Linux_b
#
[Assignment_Windows]
Windows_A
Windows_B