in reply to Re^7: Creating a random generator
in thread Creating a random generator
# In case you want to access the array mnemonically. # Depending on your version of perl, you might need to # declare one constant at a time. use constant { BOOK => 0, BEHOLDER => 1, PAGE => 2 }; my $MM = "Monstrous Manual"; my %monster_lookup = ( 'beholder' => [$MM, 1, 21], 'death kiss' => [$MM, 0, 21], 'eye of the deep' => [$MM, 0, 21], #etc... ); my $monster_type = 'beholder'; my $monster = $monster_lookup{$monster_type}; printf "Monster: %s Book: %s Beholder: %s Page: %s\n", $monster_type, +@$monster; # E.g. accessing one attribute at a time print "$monster->[BOOK]\n";
|
|---|