Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Problems using DB_File on Windows (was: Windows/UNIX)

by perleager (Pilgrim)
on Apr 21, 2001 at 07:26 UTC ( #74385=perlquestion: print w/replies, xml ) Need Help??
perleager has asked for the wisdom of the Perl Monks concerning the following question:


I have a windows and a unix machine. The following code works on UNIX but not Windows. Any idea why? and what I could fix to make it work? Also can you give me any refference for where to learn about the diffrentiallity between programming PERL on the twho machines.

############ADD MEMBER FOR HOME.CGI sub addmember { $timerss = time; use DB_File; # optional; overrides default tie %add, "DB_File", "" or die "Can't open FILENAME: $!\n"; # o +pen database tie hash to db #account-keys time-values $add{$account} = "$timerss"; #REFRESH TIME untie %add; dbmclose %add; &whosonline; }

Thank you,

2001-04-21 Edit by Corion : Changed title

Replies are listed 'Best First'.
Re: Windows/UNIX
by chromatic (Archbishop) on Apr 21, 2001 at 07:47 UTC
    perlport has some good information on things that don't work consistently between Perl platforms.

    Nothing in your code immediately stands out as Not Working. I would recommend you give us an exact error message when running under -w and strict for better answers.

Re: Windows/UNIX
by eejack (Hermit) on Apr 21, 2001 at 08:34 UTC
    Howdy perleager,

    I think windows perl does not come with DB_File capability. At least when I try to run your script I get this error: Can't locate in @INC

    I tried to pull it down using ppm but no dice.

    You might want to look at the perlport page chromatic suggested under the part about standard modules. It suggests you might be able to use AnyDBM_File - which I am not familar with, but which appears to be functioning on my windows perl.


      eejack is correct, DB_File is mainly for Unix platforms.

      I'm guessing that is your main problem: use DB_File;. But, there are binaries out there in which include DB_File for a Win32 distribution by Gurusamy Sarathy. You can ftp the files here. Hope this helps a bit.
      AnyDBM_File will use its preference for a dbm. It will always find something though because it can fall back on SDBM_File which ships with Perl.

      However if keys or values go over 2K, that will cause data corruption. So don't use SDBM_File if you can avoid it.

      Also note that if you are using one dbm and then install another, AnyDBM_File will no longer know how to read any of the data files that you previously worked with. Caveat programmer.

Re: Windows/UNIX
by Chmrr (Vicar) on Apr 21, 2001 at 08:22 UTC

    As chomatic states, perlport might turn something up. A little more information might help, though. "Doesn't work" is fairly general -- for what value of "doesn't work"? Also, what version of perl -- and is it the same on both machines? The dbmclose looks vaguely suspect to me, as that construct is depreciated in all current perls.

    Update: FYI, the following code works fine for me under ActivePerl 5.6:

    use DB_File; tie %add, "DB_File", "foo.db" or die "Can't open FILENAME: $!\n"; $add{time} = time; untie %add;

    Adding the dbmclose doesn't change it, either. Because you didn't use dbmopen to open the database, it isn't needed. Nor should it ever be, because tie has replaced it. ;>

    perl -e 'print "I love $^X$\"$]!$/"#$&V"+@( NO CARRIER'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://74385]
Approved by root
[marto]: that is to say, to the best of my knowledge, they never did.
[marto]: they have a commercial product called perlapp
[mark4]: Do you h=know how I can get pp.exe? Is there a module I can install that includes this?
[marto]: I always found Strawberry Perl on windows to be a much better environment, made life much easier
[marto]: pp. install it like you would any other module
[marto]: it probably exists in one of the PPM repositories
[marto]: failing that see the README

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2018-01-19 14:11 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (218 votes). Check out past polls.