sg has asked for the wisdom of the Perl Monks concerning the following question:
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,
Back to
Seekers of Perl Wisdom