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.