Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Super-Portable DB_File Solution

by rokadave (Sexton)
on Dec 11, 2007 at 23:21 UTC ( #656513=perlquestion: print w/replies, xml ) Need Help??

rokadave has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'm writing a small ajax responder that will need to drop into a webserver which I have absolutly no control over (no shell access), is a different architecture (Solaris on a sparc) than I develop with, and has a very default perl install. Execution under CGI does not allow me to write to a file.

I've got a very simple data requirement. I need indexed access to a specific row (not range) of data. I've got 50,000 rows of simple, small text data with a small (3-5 character) text key. The data never changes except when I want to upload a new data file.

I built a nice little application using DB_File (DB_HASH). I created the hash.db on my Linux x86_64 box and uploaded it along with a perl cgi to the sparc. It didn't work :(. I'm not sure why, either it isn't binary portable or the spark has a funky berkeley db.

Is there a native perl implementation of DB_File? Is there a way to create a more generic Berkeley hash file? Should I look towards other packages such as MLDBM? Should I go with something huge like sqlite? Should I write my own file structure and b-tree?

Further complicating my choices is the fact that my client is a mere pawn in an enourmous government burocracy and had to grovel just to get execute permissions for cgi. I had to painfully guide him through ftp chmod 0755 to even get the script to run. I need a solution that is guaranteed (or just likely) to work under any environment.

Any help is welcome!

Replies are listed 'Best First'.
Re: Super-Portable DB_File Solution
by jZed (Prior) on Dec 12, 2007 at 00:22 UTC
    SDBM and other standard DBM data files are not binary compatible across platforms, AFAIK. Probably the most robust solution is DBM::Deep, it's pure perl so you can FTP it to your site or cut and paste it into your script. Its data is cross-platform so you can FTP it. Other than that, Storable or Data::Dumper might do what you need.
Re: Super-Portable DB_File Solution
by dragonchild (Archbishop) on Dec 12, 2007 at 00:07 UTC
    DBM::Deep might also fit the bill as it's pure-perl.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      And DBM::Deep is just a single-file install, so you can ship it with your app, or even include it inline if you want a single-file app. It's really quite remarkable. That's why Stonehenge chose it for a Rock Star grant last year to enhance it for transaction support.
        (Transaction support for a highly portable database)That is great news. Thanks.
Re: Super-Portable DB_File Solution
by perrin (Chancellor) on Dec 11, 2007 at 23:27 UTC
    SDBM comes with Perl, and should be present on any Perl installation.
      Thanks! That looks like it's just the ticket.

      Annoying how google didn't know what I was looking for when I searched for portable perl db_file.

        Well, the generic term is usually dbm. You may also commonly find gdbm, which has fewer size limitations than sdbm, but it sounds like that's not an issue for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://656513]
Approved by grep
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2021-06-24 22:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (133 votes). Check out past polls.

    Notices?