# Print each state and the counties that have a 'w' in them foreach my $row_ref (@rows) { my @counties = grep{/w/i}split /\|/,$row_ref->{county_names_all}; foreach my $county (@counties) { print "$row_ref->{state} $county\n"; } } =prints WV Wirt WV Wood AK Ketchikan Gateway AK Prince of Wales-Hyder =cut