Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: conf file in Perl syntax

by Anonymous Monk
on Jun 11, 2009 at 12:34 UTC ( #770632=note: print w/ replies, xml ) Need Help??


in reply to Re^2: conf file in Perl syntax
in thread conf file in Perl syntax

$ cat hosts.conf
<Hosts>
host_1 = 192.168.1.1
host_2 = 192.168.1.2
host_3 = 192.168.1.3
</Hosts>

$ cat hosts.pl

#!/usr/local/bin/perl -w
use Config::General(ParseConfig);
$configFile='hosts.conf';
my %config = ParseConfig($configFile);
foreach my $host (keys(%{$config{Hosts}}))
{
print "Machine : $host => $config{Hosts}{$host}\n";
}

$ ./hosts.pl
Machine : host_1 => 192.168.1.1
Machine : host_2 => 192.168.1.2
Machine : host_3 => 192.168.1.3


Comment on Re^3: conf file in Perl syntax

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://770632]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-06 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls