On 2/16/06, David Prévot <[EMAIL PROTECTED]> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I have a program that works with Linux and want it to be used with W$.
> It puts a big Hash (~1,500,000 keys) in a db in order to be used by an
> other program, the same lines in each program to call it:
>
> my (%tableville);
> dbmopen(%tableville,"tablebis",0644) or die($!);
>
> the hash looks like
> $tableville{"80100;ABBEVILLE;MARCADE;CHAUSSEE"}="000;000;002;084;1010";
> but I tried with more simple ones ($tab{"toto"}="pipi") and the problem
> is the same.
>
> The problem is the format of the database : it is not the same for Linux
> and Active Perl...
> My question is : is there a db format I can use with Linux and Active
> Perl ? If yes, how can I call it with the tie() function ? (I made some
> try but I coudn't make it work under W$).
>
> I tried a part of my programs under W$, it works, but I would prefer not
> to calculate a W$ version and a Linux version (and perhaps a Mac
> version) of the database, that tooks about one hour to calculate with a
> non graphical terminal (I have no idea how much time it would take under
> W$, but I'm afraid it would bug before it ends).
>
> Sorry if my English is not good, I would accept reply in French ;)
>
> Thanks in advance.
>
> David

What's the problem? You haven't given us an error message. The sample
code works fine on both platforms for me.

If you're trying to share the same database file between platforms,
that's a different story. Different OS use different DBM by default.
Linux uses GDBM, Windows uses--I think--NDBM or SDBM, and OS X
probably uses NDBM or GDBM. The way around this is to make sure you're
losing the lowest common denominator DBM, SDBM, which is the slowest
and least versatile of the options, but is included with the deafult
Perl installation on all platforms.

    use SDBM_File;
    dbmopen(...);

You may still have problems with encodings and line-endings, and
you'll have issues switching between different processor types,
because most DBM implentations are byte-order specific. An intel
machine, whether BSD, Windows or Linux, can't read a dbm files from
PPC machines, whether they're running OS X or Linux. The only truly
portable DBM code would use DB_File, but you'll have to make sure that
Sleepycat's DB is installed in a standard location on every machine
you want to run the script.

Your best bet is going to be using something like MySQL, Postgres, or
even SQLite, which are designed to be architecture-independant.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to