perlquestion
sg
Hello,
<p>
</p><p>
In the following code, note the order of the printf statements;
in particular, note the order of the second and the third
printfs:
</p>
<code>
#!/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__
</code>
<p>
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:
</p>
<code>
5 7 8
first set of dashes------------
above first set of dashes #: [1
second set of dashes------------
y dashes------------
y: [1]
$
</code>
<p>
Question: why is the order of the output lines different from
the order of the printf statements?
</p><p>
Thanks,
</p>