Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!lll-winken!decwrl!orc!inews!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: dbm and news history Message-ID: <1990Mar11.165640.11734@iwarp.intel.com> Date: 11 Mar 90 16:56:40 GMT References: <1990Mar11.130242.11596@pegasus.com> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 64 In-Reply-To: richard@pegasus.com (Richard Foulk) In article <1990Mar11.130242.11596@pegasus.com>, richard@pegasus (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? I stole this code more-or-less from somewhere. Sorry I don't have the original author's name to give full credit. ################################################## snip snip #!/usr/bin/perl # print the appropriate line from /usr/lib/history # usage: $0 [<]article-ID[>] ... chdir "/r2/usr.lib.news" || # directory for /usr/lib/news die "Cannot chdir to /usr/lib/news ($!)"; dbmopen(HISTDB,"history",0666) || die "Cannot open history.dir/pag ($!)"; open(HIST,"$/; # add brackets if necessary (warn "No such article: $_"), next unless defined $HISTDB{$_ . "\000"}; seek(HIST, unpack('L', $HISTDB{$_ . "\000"}), 0); $_ = ; print; } ################################################## snip snip print join('',grep(s/.*"(.)".*/$1/,split(/\n/,<<))); Gimme a "J"! Gimme a "u"! Gimme an "s"! Gimme a "t"! Gimme a " "! :-) Gimme an "a"! Gimme an "n"! Gimme an "o"! Gimme a "t"! Gimme an "h"! Gimme an "e"! Gimme an "r"! Gimme a " "! :-) Gimme a "P"! Gimme an "e"! Gimme an "r"! Gimme an "l"! Gimme a " "! :-) Gimme an "h"! Gimme an "a"! Gimme a "c"! Gimme a "k"! Gimme an "e"! Gimme an "r"! Gimme a ","! :-) What's that spell?? -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/