On Wed Sep 28 17:50:35 2016, mjd@plover.com wrote: > > This is a bug report for perl from mjd@plover.com, > generated with the help of perlbug 1.39 running under perl 5.18.2. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > The following program: > > my $i; > sub announce { printf "Count %d\n", $i } > > for $i (1..3) { > announce(); > } > > It emits > > Count 0 > Count 0 > Count 0 > > But it should be > > Count 1 > Count 2 > Count 3 > > Also, when correcting that bug, please make sure this is also > corrected: > > for my $i (1..3) { > sub announce { printf "Count %d\n", $i } > announce(); > } > > It shows the same wrong behavior. > Why, in a similar circumstance, does 'print' behave differently from 'printf'? ##### $ cat 129757-other.pl my $j; sub denounce { print "Count $j\n"; } for $j (1..3) { denounce(); } $ perl 129757-other.pl Count Count Count ##### Thank you very much. -- James E Keenan (jkeenan@cpan.org) --- via perlbug: queue: perl5 status: new https://rt.perl.org/Ticket/Display.html?id=129757Thread Next