# values to be used in an array ... my @array= map /\bkingdom\|([^|]+)\|/g, <>; # and stored in a hash as individual keys my %hash; $hash{$_}++ for @array; # show: print map "kingdom $_ was $hash{$_} x
\n", keys %hash;