What is the bareword param there for? Shouldn't this be a hash?
Are you checking for failure and printing an error message? That error message will probably help you a lot more than we can, given the information we have.
dbmopen(%hash, $config_file, 0666)
or die "Couldn't open DBM: $!";
Note that dbmopen has been "largely superceded by tie":
use NDBM_File;
use Fcntl;
tie(%hash, 'NDBM_File', $config_file, O_RDWR|O_CREAT, 0640)
or die "Couldn't open NDBM: $!";
If this is a CGI script you may need to examine the server error logs for the resulting error messages, or use something like CGI::Carp to send them to the browser:
use CGI::Carp 'fatalsToBrowser';
| [reply] [d/l] [select] |
Thanks a lot for telling me about CGI::Carp.
It really helped. But here is the error message:
No such file or directory at /blah/blah/blah/cgi-bin/configure_counter
+.pl line 54.
I think that dbmopen is ougth to create
the file... Is that wrong?
param is a hash, but I think that you do not
need to put the % at the beginning. Anyway, I tried it,
still
the same message.
I need to finish this in a hurry, so I cannot user tie
now, but next time I will.
Thanks a lot for your help,
Sinan | [reply] [d/l] [select] |
| [reply] [d/l] |
Well, for one, dbmopen doesn't return a handle, according to perlfunc:dbmopen. Second, as that document mentions, dbmopen is deprecated in favor of tie. But if you want to use dbmopen, to add stuff to the DBM file, you need to populate the variable you've called param.
What's this do?
my %param;
dbmopen(%param, $config_file, 0666);
# now populate the %param hash
$param{key1} = "value1"; # or whatever makes sense
dbmclose(%param);
update And of course, as Fastolfe mentions, that first line should be dbmopen or die anyway. bad arturo!
Philosophy can be made out of anything. Or less -- Jerry A. Fodor | [reply] [d/l] [select] |
DBI 'home page': http://www.arcana.co.uk/technologia/perl/DBI
Master archive site for Perl DB information:
ftp://ftp.demon.co.uk/pub/perl/db/
Mailing list archive: /DBI/perldb-interest/
Searchable index of the dbi-users mailing list:
http://www.coe.missouri.edu/~faq/lists/dbiusers/
mysql home page: http://www.tcx.se
I didn't have much luck looking for dbmopen syntax on cpan, but
everything there uses tie to tie a hash/array to a dbm file.
But perldoc -f dbmopen says:
among other things
# print out history file offsets
dbmopen(%HIST,'/usr/lib/news/history',0666);
while (($key,$val) = each %HIST) {
print $key, ' = ', unpack('L',$val), "\n";
}
dbmclose(%HIST);
so param should at least be %param and it should be the
hash you want connected/tied (perldoc also says dbmopen is
outdated, use tie) to the dbm. I'm guessing you have a few other
things not working too.
HtH
a | [reply] |