I'm trying to compare 2 array and print the difference at a 3rd file. However how am i going to compare this 2 arrays by ignoring certain patterns:
For example:
1st array contains:
ctahci
cptcsa0
ctsata:25:seed
cptcsa1:50:seed
ctsata_1:25:seed
2nd array contains:
cptcsa0
ctsata
cptcsa1
I wanna ignore the ":25:seed" and ":50:seed" in the @removelist during comparison.
So that the output file will be:
ctahci
ctsata_1:25:seed
This is the code for me to find the difference but i got no idea on how to ignore the 2 patterns.
#!/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);;
Any ideas pls help. Thx