The stupid question is the question not asked | |
PerlMonks |
Re: Why does the first $c evaluate to the incremented value in [$c, $c += $_] ?by Jenda (Abbot) |
on Mar 05, 2014 at 10:01 UTC ( [id://1077059]=note: print w/replies, xml ) | Need Help?? |
1. Modifying a variable you use several times within an expression is begging for problems. Don't! 2. You can't use a state variable for something like this! As soon as that line gets evaluated twice, you end up in deep sh^B^Bproblems:
State variables are too global. The simplest solution I can think of is: or
Jenda
In Section
Seekers of Perl Wisdom
|
|