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
    Doing that just leads me into a problem in the next line: Can't call method "param" on an undefined value at kenesis.pl line 92, <STDIN> line1. My Syntax on that line, and the ones to follow, is/are just like the one posted in ACCESSING VALUES section of that documentation. @player = $cfg->param("player"); The configuration file that I am working with is using the "Simple" syntax. Sorry for all of the trouble over this.