phpperlflat-filedbmgdbm

Reading perl flat file db with php


I have an old flat file perl db that's part of an eCommerce site I want to migrate to a new php application.

Is it possible to read with php the "table" files have no file extension and seem not be just csv's or similar?


Solution

  • If I understand your question correctly, you have the kind of Perl database that's accessed with a so-called bound hash.

    This uses technology generically known as dbm. The most recent implementation is gdbm, a GNU version, that's described here. http://www.gnu.org.ua/software/gdbm/ It's likely (but not 100% certain) that's the version used by the Perl infrastructure of your old app.

    There's a PHP API with functions like dba_open() that also supports dbm variants. http://www.php.net/manual/en/ref.dba.php . You should be able to handle that file of yours with it.

    It's worth observing that this dba_ extension wasn't loaded in my php implementation until I enabled it explicitly. You may have to mess around with various dbm implementations until you find the one that matches. The three I know about are the original UNIX one, dbm, ndbm, and gdbm.