[qwert]Whether a character in an array/list

my $infile = shift;

open IN,$infile ||die $!;

my @blacklist = qw (chr17_ctg5_hap1 chr4_ctg9_hap1 chr6_apd_hap1 chr6_cox_hap2 chr6_dbb_hap3 chr6_mann_hap4 chr6_mcf_hap5 chr6_qbl_hap6 chr6_ssto_hap7 chrUn_gl000223);

while ( <IN> ) {
	chomp;
	my $chr = (split /\t/)[0];
	if (grep /^$chr$/,@blacklist){
		next;
	}
	print $_."\n";
}

  Check whether a character in a list/array. `grep` will be employed for convenience. 

posted @ 2012-12-08 11:51  Puriney  阅读(320)  评论(0编辑  收藏  举报