Perl Monk, Perl Meditation | |
PerlMonks |
Detect a localized variableby Sewi (Friar) |
on Nov 18, 2011 at 13:20 UTC ( [id://938813]=perlquestion: print w/replies, xml ) | Need Help?? |
Sewi has asked for the wisdom of the Perl Monks concerning the following question: Dear Monks, I got a module which handles caching of various items. Items may be changed far away from the module actually filling the cache and I want to provide a way for scripts to force cache refreshing even if the source actually getting/setting the data is another file. My idea was a global our $FORCE_REFRESH = 0;in my Cache module which should be set to 1 to force all subsequent read's to fail and refresh the cache this way:
I want My::Cache to complain (and refuse to force refreshing) if someone starts modifying the variable without using local. I don't want a My::Cache::set_force_refresh() function because I'm pretty sure people will set it without resetting it as soon as possible. Is there any way to detect if a variable is currently localized? Thanks,
Back to
Seekers of Perl Wisdom
|
|