Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I suggest an on-disk key/value database. Due to Perl's <a href="http://perldoc.perl.org/functions/tie.html" rel="noreferrer">tie function</a>, they can be used identically to normal, in-memory hashes. They'll be faster than Perl's hashes for reading/writing if your hash is very large, and they support saving/loading to disk automatically.</p> <p><a href="http://search.cpan.org/perldoc?BerkeleyDB" rel="noreferrer">BerkeleyDB</a> is an old favourite:</p> <pre><code>use BerkeleyDB; # Make %db an on-disk database stored in database.dbm. Create file if needed tie my %db, 'BerkeleyDB::Hash', -Filename =&gt; "database.dbm", -Flags =&gt; DB_CREATE or die "Couldn't tie database: $BerkeleyDB::Error"; $db{foo} = 1; # get value print $db{foo}, "\n"; # set value for my $key (keys %db) { print "$key -&gt; $db{$key}\n"; # iterate values } %db = (); # wipe </code></pre> <p>Changes to the database are automatically saved to disk and will persist through multiple invocations of your script.</p> <p>Check the perldoc for options, but the most important are:</p> <pre><code># Increase memory allocation for database (increases performance), e.g. 640 MB tie my %db, 'BerkeleyDB::Hash', -Filename =&gt; $filename, -CacheSize =&gt; 640*1024*1024; # Open database in readonly mode tie my %db, 'BerkeleyDB::Hash', -Filename =&gt; $filename, -Flags =&gt; DB_RDONLY; </code></pre> <p>A more complex but much faster database library would be <a href="http://fallabs.com/tokyocabinet/" rel="noreferrer">Tokyo Cabinet</a>, and there are of course many other options (this is Perl after all...)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload