my @find = $line[$i] =~ /(?:\A|\t)(abc\d+)(?=\t|\z)/ my %count; $count{$_}++ for @find;