in reply to random negative toggle function
For a solution perhaps more sophisticated that the classic negate-$x-each-iteration perhaps it would be illuminating to look at Easy binary toggle at fixed intervals, or perhaps Flipper, and of course, merlyn has probably written an article about this :)
IMHO the simplest is:
d:\>perl -e "print +($a += 1) %= 2 for 1..10" 1010101010
|
|---|