in reply to Re^5: porting C code to Perl
in thread porting C code to Perl
As you discovered,
int nines, predigit = 0;
is not the same as
int nines = 0; int predigit = 0;
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.
|
|---|