Sun751 has asked for the wisdom of the Perl Monks concerning the following question:
I found below code in the PerlMonks and found quite helpful to read configuration(.cfg) file,
Suppose if after reading I want to pass the content of (@CFG) to another subroutine how can that be done?
I think I am totally lost, Any suggestion, Please.
Cheers,
I tried running it with .cfg file where array @CFG holds list of hashes. its works, Now I am having problem to understand what gets initialize in this process "my $rc = do($file);"sub ReadCfg { my $file = $_[0]; our $err; { # Put config data into a separate namespace package CFG; # Process the contents of the config file my $rc = do($file); # Check for errors if ($@) { $::err = "ERROR: Failure compiling '$file' - $@"; } elsif (! defined($rc)) { $::err = "ERROR: Failure reading '$file' - $!"; } elsif (! $rc) { $::err = "ERROR: Failure processing '$file'"; } } return ($err); } # Get our configuration information if (my $err = ReadCfg('my_cfg.cfg')) { print(STDERR $err, "\n"); exit(1); }
Suppose if after reading I want to pass the content of (@CFG) to another subroutine how can that be done?
I think I am totally lost, Any suggestion, Please.
Cheers,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Reading .cfg file
by Your Mother (Archbishop) on Jul 17, 2009 at 07:32 UTC | |
Re: Reading .cfg file
by CountZero (Bishop) on Jul 17, 2009 at 06:29 UTC | |
by Anonymous Monk on Jul 17, 2009 at 08:03 UTC | |
by CountZero (Bishop) on Jul 17, 2009 at 10:11 UTC | |
Re: Reading .cfg file
by Anonymous Monk on Jul 17, 2009 at 05:14 UTC | |
Re: Reading .cfg file
by afoken (Chancellor) on Jul 18, 2009 at 10:29 UTC |
Back to
Seekers of Perl Wisdom