in reply to I need speed...

If you're asking how to make a fast lookup table, you should explore the various dbm systems since thats essentially what they are. You create a tied hash, which behaves like a normal hash, but actually saves the data in a binary file designed for fast lookups. See DB_File for more information.

Warning... untested code.

#!/usr/bin/perl -wT use strict; use DB_File; my $dbmfile = '/tmp/lookuptable'; tie my %lookuptable, "DB_File", $dbmfile, O_RDWR|O_CREAT, 0640, $DB_HA +SH or die "Cannot open file '$dbmfile': $!\n"; # do whatever it is to get the ids... my $id = '123456789'; # check lookup cache: my $cachevalue = $lookuptable{$id}; if ($cachevalue eq 'Y') { # link is ok } elsif ($cachevalue eq 'N') { # link is bad } else { # determine if it is good or bad. my $isok = 'Y'; # add the calculated value to the cache $lookuptable{$id} = $isok }

-Blake

Replies are listed 'Best First'.
Re^2: I need speed...
by Aristotle (Chancellor) on Oct 07, 2001 at 13:19 UTC
    A good suggestion; but I'd be careful about which DBM module actually gets used, because most of them have pretty limiting restrictions. SDBM f.ex, the only DBM module that ships with Perl/Win32, can only store a very small number of keys, making it next to useless for anything beyond persistent configuration information or such.
      Good point. I've always found BerkeleyDB to be more than sufficient for anything like this. I'd recommend it over most of the other dbmish inplementations.

      -Blake

        BerkeleyDB is good if you can use the BerkeleyDB module with it's advanced locking interface, but for most things with short keys and short values SDBM_File is much faster, not to mention much easier to use. This application looks like an ideal fit for it.