Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: dbm and news history Message-ID: <7383@jpl-devvax.JPL.NASA.GOV> Date: 12 Mar 90 18:27:43 GMT References: <1990Mar11.130242.11596@pegasus.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 31 In article <1990Mar11.130242.11596@pegasus.com> richard@pegasus.com (Richard Foulk) writes: : I'm having a little trouble figuring out just how to use the dbm stuff : in perl. Can someone give me an example of how to find an entry in : /usr/lib/news/history given the usual key (e.g. <123@xyz.UUCP>), : assuming the usual multi-megabyte history{,.pag} files? Two things you have to realize when accessing the history file (at least in the news system we're currently using). First, "<123@xyz.UUCP>" won't be found because the keys are canonicalized to lower case: $key =~ y/A-Z/a-z/; Second, "<123@xyz.uucp>" won't be found because there's a trailing null as part of the key. So you have to say $key .= "\0"; Now you should be able to say $data = $history{$key}. ($loc) = unpack('l',$data); seek(HIST,$loc,0); $histline = ; ($messid,$date,$artlist) = split(/\t/,$histline); or some such, depending on your news system. For a longer example see the refetch script I posted a while back. Larry