---Output:---#!/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 writ +ing:$!\n"; print $OUTFILE "$_\n" foreach (@newlist);
Adjust the regular expression to suite your requirements.
I hope life isn't a big joke, because I don't get it.
-SNL
In reply to Re: Comparing 2 arrays but ignoring certain patterns
by NetWallah
in thread Comparing 2 arrays but ignoring certain patterns
by hongping
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |