I'm trying to figure out how to replace a value in an array without changing it's position IN the array. For this project, I'm reading 10 items from a text file into an array. I have a second array with 10 values of zero.
Based on random number generation, I want to increment the number of items found based on what is found.
sub getitem
{
$item_found = rand($itemfound);
$item_found = $item_found - 1;
if ($item_found < 0) {
$item_found = $item_found * -1;
}
print "\n\n************************** $item_found ***********************\n\n";
print "You have found: $gameitems[$item_found]\n\n";
menu();
I've gotten this to find and show the random item. But I have no clue how to increment the inventory count by 1 in the second array.
YEs, this means I haven't puzzled out how to manage a multidimensional array in PERL. This is my first attempt using this language.
any pointers or idea to get me in the right direction is welcome.
Thanks!

New Topic/Question
Reply



MultiQuote





|