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

I'm looking for an alternative to my flat file storage setup for some of my perl scripts. It would be great if I had a lightweight DB I could use.

The information stored is very simple (eg. integers, 15265, 265359, 1526523) Currently all I do is retrieve my list of numbers from the file, do some work on them and append any new numbers that I've processed.

Is there a solution available that allows me to do this and can be made portable?

Replies are listed 'Best First'.
Re: Lightweight storage solution?
by Corion (Patriarch) on Jul 24, 2008 at 15:30 UTC

    See Tie::File or DBD::SQLite. You haven't stated what kind of queries you make against that file and what kind of portability you need, so it's hard to be more specific with recommendations. Storable also can be considered as a persistence solution.

      The only queries I would need to perform are checking to see if the number is listed in the file/DB or not.
        Is this one list of numbers, or is it a bunch of (labeled) lists of numbers. If the former, then a db solution may not really buy you anything. In that case just read the file and grep for your target(s).
Re: Lightweight storage solution?
by dHarry (Abbot) on Jul 24, 2008 at 15:41 UTC

    Why do you want to change? The file is very simple, a database seems overkill. Do you need support for concurrency? Is the file getting BIG? Something else?!

    There are many lightweight databases around. You might want to give CPAN or sourceforge a look.

    Personally I would probably try my luck with MySQL. maybe not so lightweighted but a lot lighter then beasts like Oracle, Sybase, MSSQL, Progress etc. etc. Installation and administration is straightforward, i.e. you don't have to be a DBA.

    Hope this helps

Re: Lightweight storage solution?
by zentara (Cardinal) on Jul 24, 2008 at 17:51 UTC
Re: Lightweight storage solution?
by broomduster (Priest) on Jul 24, 2008 at 15:33 UTC
    I
    use DB_File;
    with tied hashes a lot for this kind of thing. Since your "values" appear to be lists (as opposed to scalars), you may also need to
    use MLDBM qw(DB_File Storable); # or other choice of Serializer
Re: Lightweight storage solution?
by Anonymous Monk on Jul 24, 2008 at 15:36 UTC
    Anyone familiar with DBM::Deep?

    Looks like it might be perfect and it's a pure perl solution.

      Super Search shows a lot of recent references in several DB related questions.

      As for familiarity, dragonchild is the father :)

      Update: I'd give it a try, of course.