Hello,

In the following code, note the order of the printf statements; in particular, note the order of the second and the third printfs:

#!/c/opt/perl64/bin/perl BEGIN {(*STDERR = *STDOUT) || die;} use diagnostics; use warnings; use strict; $| = 1; my @foo; push @foo, 5; push @foo, 7, 8; printf "@foo\n"; printf "\nabove first set of dashes #: [" . #@foo . "]\n"; printf "first set of dashes------------\n"; printf "\nsecond set of dashes------------\n"; my $y = printf "\ny dashes------------\n"; printf "\ny: [$y]\n"; __END__

The output of the above code using perl 5, version 16, subversion 1 (v5.16.1) built for MSWin32-x64-multi-thread (with 1 registered patch) is given below -- note the reversal of the outputs from the second and third printf statements:

5 7 8 first set of dashes------------ above first set of dashes #: [1 second set of dashes------------ y dashes------------ y: [1] $

Question: why is the order of the output lines different from the order of the printf statements?

Thanks,


In reply to Order of printf statements vs order of actual lines printed out by sg

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.