I now you all will kill me for this but here goes..
this is slow:
foreach (keys %h)
{if (/some regex/) {$h2{$_}=$h{$_}}
}
In other words, extract a new hash from an existing one by searching for
primary keys matching a regex. (Please don't get off on your solutions to
this or syntax corrctions- that's not the point of this message..)
Particularly useful for tied hashes using GDBM where the key is actually a
compound key such as 'Tom Smith+Mycity+NY+13404' we could find all NY-ers
using
foreach (keys %h) {if (/\+NY\+/) {$h2{$_}=$h{$_}}
but try it on 50,000 keys.. ACK, time for a coffee break.
Now I'm not even sure what mechanism to ask for except something far more
optimal be made available in the language. A way to slice it in n-space as
opposed to n*n?
I guess what I really would need for speed is primary/secondary indices and
I suspect the gentry here will (rightfully) send me packing for my MySQL
DBI. But I thought I'd suggest this possibility since Larry said this is a
brainstorming exercise right now.
Something like secondary indices for hashes of hashes perhaps?
Ducking and covering..
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com