hongping has asked for the wisdom of the Perl Monks concerning the following question:
2nd array contains:ctahci cptcsa0 ctsata:25:seed cptcsa1:50:seed ctsata_1:25:seed
I wanna ignore the ":25:seed" and ":50:seed" in the @removelist during comparison. So that the output file will be:cptcsa0 ctsata cptcsa1
This is the code for me to find the difference but i got no idea on how to ignore the 2 patterns.ctahci ctsata_1:25:seed
Any ideas pls help. Thx#!/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);;
|
|---|