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

Re: Updating Hash from a config file

by toolic (Bishop)
on Oct 12, 2007 at 13:36 UTC ( [id://644482]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2025-04-28 21:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.