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