package RandWritingImplement; use parent -norequire, 'RandThing'; sub new { my ($class) = @_; my @values = qw(pencil pen marker crayon chalk); return $class->SUPER::new (@values); } package RandWritingSurface; use parent -norequire, 'RandThing'; sub new { my ($class) = @_; my @values = qw(paper parchment slate hide stone); return $class->SUPER::new (@values); } #### sub _random { my ($list,$key) = @_; my @random_array; if (ref($list) eq "HASH") { if ($list->{$key}) { @random_array = @{$list->{$key}}; } elsif ($key eq 'keys') { @random_array = (keys %{$list}); } elsif ($key eq 'all') { @random_array = map(@{$list->{$_}},keys %{$list}); } else { die q(You need to select a key from the hash, "all" keys, or just "keys".); } } elsif (ref($list) eq "ARRAY") { @random_array = @{$list}; } else { die q(What are you doing? You didn't enter a hash or an array.); } return $random_array[rand @random_array]; }