my %cons; my $text; my $count; while(<>){ $text = m/\|(.*?\|){5}(.*?)\|(.*?\|){3}(SNOMEDCT)/; if ($text){ print "$_\n"; } $cons{$2}++; } my $count = keys %cons; print "$count";