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 avoiding work at the Monastery: (3)
As of 2026-01-24 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (126 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.