|Perl Monk, Perl Meditation|
Re^6: porting C code to Perlby RonW (Parson)
|on Oct 25, 2017 at 20:47 UTC||Need Help??|
As you discovered,
int nines, predigit = 0;
is not the same as
I'm surprised int nines, predigit = 0; is even valid C syntax.1
However, nines, predigit = 0; is valid C syntax, but treats nines and predigit = 0 as 2 separate expressions. nines is evaluated in void context (so, the warning you got), while 0 is evaluated in an integer context and then assigned to predigit (effectively, predigit is in lvalue context).
An alternate syntax that would have zero'd both is nines = predigit = 0; which may be what the author intended to write (but he should have gotten the warning).
1 Note that in Perl, my ($nines, $predigit) = 0; will init $nines to 0 and leave $predigit undefined. Also, it doesn't give a warning.