sub get_rules { my %classification; while (my $rule = <DATA>){ my ($animal, $catagory) = $rule =~ /\AAn?\s(\w+)\sis\san?\s(\w+)\.\s*\z/; $classification{$animal} = $catagory; } return %classification; } __DATA__ A cat is a mammal. A dog is a mammal. A bluejay is a bird. A snake is a reptile. A lizard is a reptile. A frog is an amphibian. An owl is a bird. A carp is a fish.