Well thinks to everyones help and some tinkering I got it to create the file and write to it, but now I have having trouble getting it to read from the file
sub load_game {
$cfg->read("'$ENV{HOME}/.kenesis'");
@player = $cfg->param("player");
@enemy = $cfg->param("enemy");
$completed_quests = $cfg->param("quest");
$special_item = $cfg->param("items");
$class = $cfg->param("class");
#main_menu();
print "@player\n";
print "@enemy\n";
print "$completed_quests\n";
print "$special_item\n";
print "$class\n";
exit;
}
I get the following error
Can't call method "read" on an undefined value at kenesis.pl line 93, <STDIN> line 1.. The thing is all of my variables are defined
our @player;
our $completed_quests = 0;
our $special_item = "none";
our @enemy;
our $class = "null";
our $cfg;
.
The line that the error is complaining about, line 93, is this line
$cfg->read("'$ENV{HOME}/.kenesis'");
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.