My
article on
www.perl.com goes into some of the techniques, especially the one
Masem describes. The last example does just what you say, and it's fairly speedy too. (I haven't benchmarked it, but it uses the fastest retrieval mechanisms together.)
Wow... I feel like a merlyn or a Dominus. *sniffle*