ctahci cptcsa0 ctsata:25:seed cptcsa1:50:seed ctsata_1:25:seed #### cptcsa0 ctsata cptcsa1 #### ctahci ctsata_1:25:seed #### #!/usr/intel/bin/perl @testlist = qw(ctahci,cptcsa0,ctsata:25:seed,cptcsa1:50:seed,ctsata_1:25:seed) @removelist =qw(cptcsa0,ctsata,cptcsa1) my $outfile = "./new.list"; %removelist=map{$_=>1} @removelist; @newlist=grep(!defined $removelist{$_}, @testlist); # creating new list open (OUTFILE, ">$outfile") or die "Cannot open $outfile for writing \n"; ); print OUTFILE "$_\n" foreach (@newlist);;