in reply to Re^3: Trouble working with Config::Simple
in thread Trouble working with Config::Simple
Tell me this: at what point does $cfg get a value from &Config::Simple::new when the program is requested to load a game via load game string coming in from STDIN?
Between declaration of $cfg variable on line 31 and call to &load_game sub on line 83, $cfg remains undefined. And, what is very first statement of &load_game? It is a call to a(n) (unknown) method read on yet-to-be-defined $cfg. That is the reason for the error message.
$cfg needs to be defined (even) in &load_game sub before a method could be called on it, much like in the first statement of &new_game sub on line 107. You can do one of at least two things ...
sub load_game { # No need for separate "$cfg->read( ... )". $cfg = Config::Simple->new( 'file' ); # or ... $cfg = Config::Simple->new; $cfg->read( 'file' ); ... }
Note that the solution in both forms is already presented in "READING THE CONFIGURATION FILE" section of pod.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Trouble working with Config::Simple
by vendion (Scribe) on Jul 13, 2008 at 02:15 UTC |