You can look into using the DB_File module and tie() using the $DB_BTREE hash bindings as documented in DB_File/"In Memory Databases". The Tie::IxHash module from CPAN might also be instructive.