in reply to Updating Hash from a config file

Regarding requests for suggestions to improve your code's robustness...

My guess is that you are probably not using the strictures, since $config_file is not declared with my (at least, not in your sub):

use warnings; use strict;

When accessing an environment variable, it is a good practice to test if it is defined. If it is not defined, you could either die (as shown below), or assign it a default value:

my $config_file = (defined $ENV{'CONFPATH'}) ? $ENV{'CONFPATH'} : die "Error: CONFPATH not defined.\n";

Should <CFILE> really be <CONFFILE>?

It is also a good practice to close a filehandle when you are done.

These tips probably do not solve your specific problem, but hopefully they are small steps toward more robust code.

Replies are listed 'Best First'.
Re^2: Updating Hash from a config file
by Viki@Stag (Sexton) on Oct 12, 2007 at 13:50 UTC
    Thanks for the suggestions...

    And also i Will try using Config::Simple, it appears to be compatible with the structure of my config file...

    Thank you Monks