Hi, I start working with <format> to produce some report, all is nice however in final spool records are in other order, completely different then they were done in script. Total confuse , looks like a bug for me. I have series of <format> handls pointing to the same file, I also do <print> to the same file. I figured it out that I can solve this doing OPEN/CLOSE for each <write>, but probably it would be too much. I post my test script, expecting output file records be in order of $cc.
Appreciate you advice, I looked at reporting method too and might use them later, but for now I need to solve this problem to get good sleep. Really can't understand, what is behind this <write>, where data is actually written to >>outfile or some temp storage and then all synced at the end? Or iti could be because I use very same file '>>spool.dat' for all filehandles. Is there any COMMIT in Perl. I'm new to Perl, really blown away how compact and powerful it is, but need more system knowledge. Any info appreciated, here is my code below:
Best to all monks Trent P.S. I'm testing this on WindowsXP with latest ActivePerl.
#!/usr/bin/perl use strict; use warnings; my $cc="1"; unlink ('spool.dat'); open (OUT_LOG, '>>spool.dat'); open (OUT_HEADER, '>>spool.dat'); open (OUT_DETL, '>>spool.dat'); open (OUT_FOOT, '>>spool.dat'); open (OUT_BR, '>>spool.dat'); #========================================================= format OUT_HEADER= @<<<==== f0rmat HEADER HEADER HEADER Page : @<<< $cc, $cc . format OUT_DETL= @<<<======== f0ramt detail line ======================= $cc . format OUT_FOOT= @<<<======== f0rmat ===========FOOTER $cc . format OUT_BR= @<<<========= fOrmat BREAK $cc . #===================================================== write OUT_HEADER; $cc++; write OUT_DETL; $cc++; write OUT_DETL; $cc++; write OUT_DETL; $cc++; write OUT_BR; $cc++; print OUT_LOG "$cc ................print after 1st break \n"; $cc++; write OUT_DETL; $cc++; write OUT_DETL; $cc++; write OUT_DETL; $cc++; write OUT_BR; $cc++; print OUT_LOG "$cc ...............print after 2nd break \n"; $cc++; write OUT_FOOT; $cc++; print "basta \n";

In reply to <write format> records order error by trento

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.