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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.