Thread replace nth occurence: Code verstehen
(16 answers)
Opened by Student87 at 2013-03-10 11:04 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 use feature 'state'; sub foo { state $i++; $i=shift()-1 if @_; return $i; } foo 1; print foo."\n" for 0..9; foo 0; print foo."\n" for 1..5; |