in reply to Re: A TRUE-once variable
in thread A TRUE-once variable

This is derived from an example in the Perl Developer's Dictionary and it's a cool trick if you can stomach it.

$a=0; $_=0; while($_++<10) { if (! $a..(!$a)) { print "True!\n"; } else { print "False!\n"; } $a++; }
The if with the .. operator there returns true exactly once (so long as $a isn't externally modified) for the entire life of the program.

You can make the example a bit more concise using this:

$a=0; $_=0; while($_++<10) { if (! $a..(!$a++)) { print "True!\n"; } else { print "False!\n"; } }
But using an auto-increment in an expression where the target variable appears twice makes me nauseous. Probably indigestion from my C days.