Newsgroups: comp.lang.perl Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!alberta!herald.usask.ca!ccu.umanitoba.ca!rahardj From: rahardj@ccu.umanitoba.ca (Budi Rahardjo) Subject: Pattern matching of a large dbm file (slow indexing) Message-ID: <1991May6.163310.21805@ccu.umanitoba.ca> Followup-To: comp.lang.perl Keywords: pattern matching, assoicative array, dbm Sender: rahardj@ccu.umanitoba.ca (Budi Rahardjo) Organization: University of Manitoba, Winnipeg, Canada Distribution: world Date: Mon, 6 May 91 16:33:10 GMT Lines: 24 How do I get a fast pattern matching in a large associative array ? I have a large associative array (approx. 17000), read from a dbm file. I'd like to match a pattern with the contents of the array. Assigning the index/keys to an array takes forever ... , never mind doing the matching. dbmopen(RECORD,"dbtest",0666) || die "Can't open dbm file"; @k = keys(%RECORD); <====== this takes almost 9 seconds !! For comparison, doing a grep thru a flatfile (with the same contents) takes 2 secs. If I do several "@k = keys(%RECORD);", this is going to be a problem. Is there a way I can iterate over dbm file without stepping thru the index/keys ? (Basically doing a 'grep' on the contents). Or maybe read the raw-dbm file (without the index), ie treat it as a flat file ... Thanks, -- budi