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

In my opinion the ?^? trick is a bit too much of... a trick.

First of all, one should always do reset() after a use of ??. But the status of ?? is package scoped, so you might get scary side-effects if you use a function that uses ?? inside a loop where you used the first ??.

For instance, say that you modify your last snippet:
sub prettify { # Just code that uses ??. } while(<DATA>){ chomp; print ",\n" unless ?^?; print prettify($_); } __DATA__ foo bar blah
Evil indeed.

This is the same problem as with not localized usage of $_, e.g. when people do while (<FOO>) {} without an explicit local() on $_. (I know no way to localize the status of ??.)

-Anomo