#!/usr/bin/perl use strict; no strict 'refs'; use warnings; my $in16S = '/root/Desktop/pro.faa'; open I16S, '<', $in16S; my %r_genus16S; my ($genus16s) = ; while ( defined( ${'genus16S'} = readline(*I16S) ) ) { if ( $_ =~ />(\w+)\s/ ) { ${'genus16S'} = $1; } if ( exists $${'genus16S'}{ ${'genus16S'} } ) { print { 'I16S'; } $_; $${'genus16S'}{ ${'genus16S'} } = 'p'; next; } } my $no16S = 0; foreach $_ ( keys %${ 'r_genus16S'; } ) { if ( $${'genus16S'}{$_} eq 'n' ) { ++$no16S; print "$_\n"; next; } } close I16S;