PDA

View Full Version : why isnt my database created ?


skipion
04-05-2006, 05:55 PM
Hello, I want to use a dbm file to store things in.
However I'm stuck at opening the database, I get the errormessage: Couldnt open database #19-9-15-16, No such file or directory; aborting

I don't know why it doesnt create the database.. though I'm sure one of you guys can help me...

my script : (only posted the necessary)


#!/usr/bin/perl
use CGI;
$q=new CGI;
use SDBM_File;
print "Content-Type: text/html; charset=utf-8\n\n";

tie(%map, 'SDBM_File', 'goal.sdbm', O_RDWR|O_CREAT, 0666) or die "Couldn't open database #19-8-15-16: $!; aborting";

FishMonger
04-05-2006, 06:10 PM
You need to use the Fcntl module to import the constants/names.

use CGI;
$q=new CGI;
use Fcntl; # For O_RDWR, O_CREAT, etc.
use SDBM_File;

KevinADC
04-07-2006, 01:21 AM
Yep, it's right in the POD of the module:


SYNOPSIS

use Fcntl; # For O_RDWR, O_CREAT, etc.
use SDBM_File;

tie(%h, 'SDBM_File', 'filename', O_RDWR|O_CREAT, 0666)
or die "Couldn't tie SDBM file 'filename': $!; aborting";

# Now read and change the hash
$h{newkey} = newvalue;
print $h{oldkey};
...

untie %h;