in reply to Comparing 2 arrays but ignoring certain patterns
---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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing 2 arrays but ignoring certain patterns
by hongping (Novice) on Jun 29, 2012 at 06:53 UTC | |
by NetWallah (Canon) on Jun 30, 2012 at 04:36 UTC | |
by AnomalousMonk (Archbishop) on Jun 30, 2012 at 13:07 UTC | |
|
Re^2: Comparing 2 arrays but ignoring certain patterns
by hongping (Novice) on Jul 03, 2012 at 06:18 UTC |