You should be able to do the whole thing including file_C in one pass of file_A.
#!perl -slw use strict; use vars qw[$NEW_A]; use Data::Dumper; use Inline::Files '-backup'; local $,=', '; my %b = map{ ( '1'.$_->[0] => 1, '4'.$_->[1] => 1, ) } map{ [ (split':')[0,3] ] } <FILE_B>; my %c = map{ $_ => 1 } map{ (split':')[2] } <FILE_C>; #print Dumper \%b, \%c; open NEW_A, "> $NEW_A" or die $!; while(<FILE_A>) { chomp; my @fields = split':'; print( "Removing '$_' from FILE_A because field 1:'$fields[0]' not + in FILE_B"), next if !exists $b{ '1'.$fields[0] }; print( "Removing '$_' from FILE_A because field 4:'$fields[3]' not + in FILE_B"), next if !exists $b{ '4'.$fields[3] }; print( "Removing '$_' from FILE_A because field 3:'$fields[2]' not + in FILE_C"), next if !exists $c{ $fields[2] }; print NEW_A $_, $/; } __FILE_A__ 1:*:Z:A:* 2:*:Y:B:* 3:*:X:C:* 4:*:Z:D:* 5:*:Y:E:* 6:*:X:F:* 7:*:T:G:* __FILE_B__ 1:*:*:A:* 2:*:*:B:* 3:*:*:C:* 4:*:*:D:* 5:*:*:E:* 6:*:*:F:* __FILE_C__ *:*:Z:*:* *:*:Y:*:* *:*:T:*:* __NEW_A__ 1:*:Z:A:* 2:*:Y:B:* 4:*:Z:D:* 5:*:Y:E:*
Examine what is said, not who speaks.
The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.
In reply to Re: hash jerkin
by BrowserUk
in thread hash jerkin
by rerunn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |