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:
{ local $My::Cache::FORCE_REFRESH=1; &some_sub_requesting_the_data; }
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,
Sebastian
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Detect a localized variable
by Anonymous Monk on Nov 18, 2011 at 13:44 UTC | |
by Anonymous Monk on Nov 18, 2011 at 13:47 UTC | |
by Sewi (Friar) on Nov 18, 2011 at 14:01 UTC | |
by Sewi (Friar) on Nov 18, 2011 at 13:58 UTC | |
|
Re: Detect a localized variable
by Anonymous Monk on Nov 18, 2011 at 13:47 UTC | |
|
Re: Detect a localized variable
by Perlbotics (Archbishop) on Nov 19, 2011 at 14:25 UTC |