in reply to use of uninitialized value in hash element problem
If you're to use Config::Tiny as 1nickt suggested (and I recommend), here's an example on its use.
This is a simple example of a basic config file:
[Database] enable_replication = 0 master_locked = 0 slave_servers = 0 master_source = DBI:mysql:name:master.example.com: master_user = username master_pass = password test_mode_source = DBI:SQLite:t/db_test.db [Logging] verbose = 99
Code that uses the config:
#!/usr/bin/perl use warnings; use strict; use Config::Tiny; my $file = 'config.conf'; my $config = Config::Tiny->read($file); # get the master_user for the Database my $db_user = $config->{Database}{master_user}; print "$db_user\n"; # get the logging level my $verbose = $config->{Logging}{verbose}; print "$verbose\n";
With a config parser module, everything is consistent. You don't have to worry about the amount of whitespace on each side of the delimiter (=) or empty lines in the file, and everything is put into a nice clean hash for you.
-stevieb
|
|---|