Here the exactly example. I match the file A with the file B through the keys "l100107,bbbbbb,a_0100" so I decrement the $qtd from file A in this example 16 and 24 till 0. Notice that if you sum up this two values they are the $max of file B 40. There is no possibility that my process result different values from both files. I put the $tot in the result file to explain the flow.
File A l100107,bbbbbb,a_0100,loc,13,16 l100107,bbbbbb,a_0100,loc,14,24 File B l100107,bbbbbb,a_0100,40 Result File l100107,bbbbbb,loc,13,40,15 l100107,bbbbbb,loc,14,40,23 l100107,bbbbbb,loc,13,40,14 l100107,bbbbbb,loc,14,40,22 l100107,bbbbbb,loc,13,40,13 l100107,bbbbbb,loc,14,40,21 l100107,bbbbbb,loc,13,40,12 l100107,bbbbbb,loc,14,40,20 l100107,bbbbbb,loc,13,40,11 l100107,bbbbbb,loc,14,40,19 l100107,bbbbbb,loc,13,40,10 l100107,bbbbbb,loc,14,40,18 l100107,bbbbbb,loc,13,40,9 l100107,bbbbbb,loc,14,40,17 l100107,bbbbbb,loc,13,40,8 l100107,bbbbbb,loc,14,40,16 l100107,bbbbbb,loc,13,40,7 l100107,bbbbbb,loc,14,40,15 l100107,bbbbbb,loc,13,40,6 l100107,bbbbbb,loc,14,40,14 l100107,bbbbbb,loc,13,40,5 l100107,bbbbbb,loc,14,40,13 l100107,bbbbbb,loc,13,40,4 l100107,bbbbbb,loc,14,40,12 l100107,bbbbbb,loc,13,40,3 l100107,bbbbbb,loc,14,40,11 l100107,bbbbbb,loc,13,40,2 l100107,bbbbbb,loc,14,40,10 l100107,bbbbbb,loc,13,40,1 l100107,bbbbbb,loc,14,40,9 l100107,bbbbbb,loc,13,40,0 l100107,bbbbbb,loc,14,40,8 l100107,bbbbbb,loc,14,40,7 l100107,bbbbbb,loc,14,40,6 l100107,bbbbbb,loc,14,40,5 l100107,bbbbbb,loc,14,40,4 l100107,bbbbbb,loc,14,40,3 l100107,bbbbbb,loc,14,40,2 l100107,bbbbbb,loc,14,40,1 l100107,bbbbbb,loc,14,40,0

In reply to Re^4: how to avoid full scan in file. by EBK
in thread how to avoid full scan in file. by EBK

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.