|
Posted by szr on June 30, 2008, 6:37 pm
Please log in for more thread options smallpond wrote:
> alex.turchin@gmail.com wrote:
>> On Jun 30, 3:08 pm, Mark Clements
>>> alex.turc...@gmail.com wrote:
>>>> I have an old and rather large (thousands of lines of code) piece
>>>> of perl software that utilizes (in numerous places) NDBM databases,
>>>> including dbmopen() etc. calls. This code has now been moved by the
>>>> website administrator to a different UNIX platform that does not
>>>> support NDBM.
>>>> Unfortunately I do not have the resources to completely rewirte the
>>>> code to utilize a different database. Even more importantly, all of
>>>> the data the software uses (unique to the software and took months
>>>> of work to enter) is in the NDBM format.
>>>> I am therefore looking for a way to obtain perl support for the
>>>> NDBM format and corresponding function calls (dbmopen, dbmclose)
>>>> on a system that does not natively support them. Any thoughts
>>>> would be greatly appreciated!
>>> Hmmm.
>>>
>>> http://perldoc.perl.org/functions/dbmopen.html
>>>
>>> (quoted)
>>> **
>>> You can control which DBM library you use by loading that library
>>> before you call dbmopen():
>>>
>>> use DB_File;
>>> dbmopen(%NS_Hist, "$ENV/.netscape/history.db")
>>> or die "Can't open netscape history file: $!";
>>>
>>> **
>>>
>>> Can you not install NDBM_File and add a
>>>
>>> use NDBM_File;
>>>
>>> to the script(s)?
>>>
>>> http://search.cpan.org/~rgarcia/perl-5.10.0/ext/NDBM_File/NDBM_File.pm
>>>
>>> Mark- Hide quoted text -
>>>
>>> - Show quoted text -
>>
>> Unfortunately no longer have access to the old platform so can't dump
>> the files out :(
>>
>> With respect to using NDBM_File - will that work in absence of ndbm
>> support on the underlying UNIX platform? I don't have admin
>> privileges to the system and have to beg the admin to install stuff
>> like Perl modules for me - would like to minimize trial & error if
>> possible if you know what I mean :)
>>
>> Thanks!
>> Alex
>
>
> NDBM_File is standard with perl 5.10 and is not available for earlier
> versions of perl.
Not true, it works in both 5.8.8 and 5.10.0 for me (see below.)
> perl --version
>
> This is perl, v5.10.0 built for i686-linux
>
> perl -e 'use NDBM_File; dbmopen(%h, "foo", 0666)'
>
> Creates two files: foo.dir and foo.pag
> file foo.dir
> foo.dir: GNU dbm 1.x or ndbm database, little endian
That works for 5.8.8 as well:
$ perl5.8.8 -e 'use NDBM_File; dbmopen(%h, "foo5.8.8", 0666)'
$ perl5.10.0 -e 'use NDBM_File; dbmopen(%h, "foo5.10.0", 0666)'
They both create the two files you mentioned:
-rw-r--r-- 2 root root 12288 Jun 30 15:36 foo5.8.8.dir
-rw-r--r-- 2 root root 12288 Jun 30 15:36 foo5.8.8.pag
-rw-r--r-- 2 root root 12288 Jun 30 15:36 foo5.10.0.dir
-rw-r--r-- 2 root root 12288 Jun 30 15:36 foo5.10.0.pag
--
szr
|