Let's try a simple example for your program. Let's just say that you wanted to have multiple characters. You could have %characters hold them, with their name as the key, so that $characters{'Bob the Fighter'} would hold Bob's info. What is Bob's info? well, he'll have Attributes, Feats, Skills, Level, and so forth. Each of those could be a hash storing more detailed info. Let's initialize a sample:
To access some of Bob's data, we de-reference the reference with the arrow operator: $character{'Bob the Fighter'}->{'Attributes'}->{'Str'} would equal 10.$characters{'Bob the Fighter'} = { #The brackets create a reference t +o an anonymous hash. 'Attributes' => { # We're nesting a second hash 'Str' => 10, 'Dex' => 10 }, #Done with that hash 'Level' => 1, #Storing a normal scalar 'Feats' => { #Another hash! 'Light_Armor' => 1 #Treating as a boolean } #done with Feats Hash }; #done with hash that is stored in $characters{'Bob the Fighter' +}
References are key to any complicated data manipulation in Perl. I suggest experimenting.
In reply to Re: Daft text adventure project
by swiftone
in thread Daft text adventure project
by Tiefling
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |