Then the author goes on to give a suggested usage of this module:tied(%hash}->push( { slub => 'slob' } ); # $hash{'slub'} eq 'slob' tied(%hash)->unshift( { slub => 'slab' } ); # $hash{'slub'} eq 'slab' tied(%hash}->shift(); # $hash{'slub'} eq 'slob' tied(%hash)->pop(); # $hash{'slub'} is now not defined
the obvious application is for preferences. In a CGI app you could tie in the bottom most hash to a database with default all-users' preferences, the second layer with the current user's preferences, the layer above that with the per-session preferences and the layer above that with the per-request values.
In other words, as you continue to layer on preferences, the access of those preferences will pull a value from the hash, whose actual current value will depend on whether one of the new layers unshifted a value onto that hash key.
But I have two issues with this intended use:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I dont agree with the suggested use of Tie::Hash::Layered
by Masem (Monsignor) on Aug 06, 2001 at 22:11 UTC |