Hmm, probably well known but ... I have not met any direct warning of this problem so far.
our %SOME_CONFIG = ( a => 1, b => 2, c => 3, ); ... while (my($k,$v) = each %SOME_CONFIG) { if( ... ) { return; # or last, or throw exception } } You probably see the problem - when this code is re-executed (next request), the loop iterates just over 'the rest' of the hash. Does there exist some way to protect before this problem (some kind of auto-destructor, finally, whatever which would automatically rewind the hash internal iterator while leaving the context)?