in reply to A TRUE-once variable
Include the code above in your program somewhere early, and use it like this:sub Trueonce::TIESCALAR { my $s=1; bless \$s, $_[0]; } sub Trueonce::FETCH { my($self)=@_; local $_=$$self; $$self=0; return $_; } sub Trueonce::STORE {}
For some reason I'm in a tie() mood today...tie $f, "Trueonce"; print $f, "\n"; # 1 print $f, "\n"; # 0 print $f, "\n"; # 0 print $f, "\n"; # 0
|
|---|