home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
- #
- # xpost -- given article id's, check news history dbm file
- # for what newsgroups they're in. shows how to
- # use associative arrays and bind them to external files.
-
- $HIST = '/usr/local/lib/news/history';
- dbmopen(HIST,$HIST,0666) || die "$0: couldn't dbmopen $HIST: $!\n";
- open HIST || die "$0: couldn't open $HIST: $!\n";
-
- foreach $key ( @ARGV ) {
- $key =~ tr/A-Z/a-z/;
- $key = "<$key>" if $key !~ /^<.*>$/;
- $key .= "\000";
- if (!defined $HIST{$key}) {
- print stderr "no article $key\n";
- next;
- }
- ($pos) = unpack('L',$HIST{$key});
- seek(HIST,$pos,0);
- $line = <HIST>;
- print $line;
- }
-