use strict; use warnings; my $captains = "kirkpicard"; my %starship = ( 'EntTOS'=>0, 'EntA'=>0, 'EntD'=>0, 'EntE'=>0, ); trivia ($captains,\%starship); print "Kirk was on Enterprise #: $starship{EntTOS}, $starship{EntA}\n"; print "Picard was on Enterprise #: $starship{EntD}, $starship{EntE}\n"; sub trivia {, my ($captains, $starship_ref) = shift; %starship = %{$starship_ref}; if ($captains =~ m/(kirk)/) { $starship {'EntTOS'} = 1; $starship {'EntA'} = 2; } if ($captains =~ m/(picard)/) { $starship {'EntD'} = 4; $starship {'EntE'} = 5; } return %starship; } #### Kirk was on Enterprise #: 1, 2 Picard was on Enterprise #:4, 5