in reply to add values with hash

As igelkott says a HoA is the way to go. It looks as though monkey is the record separator. Setting Perl's record separator might help.
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Indent = 1; $/ = q{monkey}; my %hash; while (<DATA>){ my ($country, $fox_hour) = /forest\s+(\w+).*-fox\s+(\d{4})/s; next unless $country; push @{$hash{$country}}, $fox_hour; } print Dumper \%hash; __DATA__ forest France -wolf -toad -fox 1350 monkey land -dog -cat -slug forest France -deer -swan -fox 1426 monkey forest USA -deer -swan -fox 1560 monkey
outputs
$VAR1 = { 'France' => [ '1350', '1426' ], 'USA' => [ '1560' ] };
update: added link