home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeJava and XSLTSearch this book

8.219. Tie::Memoize

Adds data to the hash when needed. That is, Tie::Memoize allows a tied hash to autoload all its values on first access and to use the cached value on subsequent accesses. Read accesses will result in one of the Tie::Memoize functions being called. Write accesses will act as if you're operating on a normal hash. For example:

#!/usr/local/bin/perl -w
require Tie::Memoize;
tie %hash, 'Tie::Memoize', \&fetch, $DATA, \&exists,
    {%ini_value}, {%ini_existence};
sub fetch { ... }
sub exists { ... }


Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.