Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to create a DBM database in Perl

Reply
Thread Tools

How to create a DBM database in Perl

 
 
Topher
Guest
Posts: n/a
 
      11-27-2003
Hi,

I would appreciate some help with this. I am trying to create an admin
section for my local table tennis (yes, it's a manly sport I know...)
site and am having trouble creating any databases.

The code I have for doing this is as follows:

## write

dbmopen (%clubs, $const_database_path."clubs", 0666);

die("club id already exists!") if ($clubs{$club_id} ne "");

$clubs{$club_id} = $club_name."§".$club_short_name."§".$club_location 1."§".$club_location2."§".$club_location3."§".$clu b_location4."§".$club_postcode."§".$club_map_href. "§".$club_map_text."§".$club_website_href."§".$clu b_notes."§".$club_secretary_name."§".$club_secreta ry_add1."§".$club_secretary_add2."§".$club_secreta ry_add3."§".$club_secretary_add4."§".$club_secreta ry_postcode."§".$club_secretary
home_tel."§".$club_secretary_mobile_tel."§".$club_ secretary_work_tel."§".$club_secretary_email;


dbmclose (%clubs);


I'm not too hot on this Perl business and am basically winging it with
a bit of help from a mate every now and again, but can't seem to find
anything that shows why this is not happening. I have a file
'mkttl.conf', which is linked to earlier on in the script using
require("mkttl.conf");

In mkttl.conf I define $const_database_path as
$ENV{"SITE_ROOT"}."\mkttl_concept\databases\"

I have created the databases directory, so there should be no problems
there.

I'm not getting error messages, it's just not working - annoying as
hell!

If it's any use I am using Xitami, which is the server that I have
downloaded to test scripts on before I upload stuff.

Thanks very much, if you need any more info please ask!
 
Reply With Quote
 
 
 
 
joeri
Guest
Posts: n/a
 
      11-27-2003

"Topher" <> wrote in message
news: m...
> Hi,
>
> I would appreciate some help with this. I am trying to create an admin
> section for my local table tennis (yes, it's a manly sport I know...)
> site and am having trouble creating any databases.
>
> The code I have for doing this is as follows:
>
> ## write
>
> dbmopen (%clubs, $const_database_path."clubs", 0666);
>
> die("club id already exists!") if ($clubs{$club_id} ne "");
>
> $clubs{$club_id} =

$club_name."§".$club_short_name."§".$club_location 1."§".$club_location2."§".
$club_location3."§".$club_location4."§".$club_post code."§".$club_map_href."§
".$club_map_text."§".$club_website_href."§".$club_ notes."§".$club_secretary_
name."§".$club_secretary_add1."§".$club_secretary_ add2."§".$club_secretary_a
dd3."§".$club_secretary_add4."§".$club_secretary_p ostcode."§".$club_secretar
y
>

home_tel."§".$club_secretary_mobile_tel."§".$club_ secretary_work_tel."§".$cl
ub_secretary_email;
>
>
> dbmclose (%clubs);
>
>


What doesn't seem to be working for you? What do you expect this code to do?

J


 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      11-27-2003
Topher wrote:
> I am trying to create an admin section for my local table tennis
> (yes, it's a manly sport I know...) site and am having trouble
> creating any databases.
>
> The code I have for doing this is as follows:
>
> ## write
>
> dbmopen (%clubs, $const_database_path."clubs", 0666);


Should better be:

dbmopen (%clubs, $const_database_path."clubs", 0666)
or die "Couldn't open database\n$!";

or something like that. That will result in an error message if e.g.
$const_database_path does not contain a valid path (which I doubt it
does, see below).

> die("club id already exists!") if ($clubs{$club_id} ne "");
>
> $clubs{$club_id} =
> $club_name."§".$club_short_name."§".$club_location 1."§".
> $club_location2."§".$club_location3."§".$club_loca tion4."§".
> $club_postcode."§".$club_map_href."§".$club_map_te xt."§".
> $club_website_href."§".$club_notes."§".$club_secre tary_name."§".
> $club_secretary_add1."§".$club_secretary_add2."§".
> $club_secretary_add3."§".$club_secretary_add4."§".
> $club_secretary_postcode."§".$club_secretaryhome_t el."§".
> $club_secretary_mobile_tel."§".$club_secretary_wor k_tel."§".
> $club_secretary_email;


Without knowing anything about the rest of your application, including
how all those variables are populated, I have a feeling that your data
structure leaves room for improvements. But if you want advice in
that respect, you'd better explain more about what you are actually doing.

<snip>

> I have a file 'mkttl.conf', which is linked to earlier on in the
> script using require("mkttl.conf");
>
> In mkttl.conf I define $const_database_path as
> $ENV{"SITE_ROOT"}."\mkttl_concept\databases\"


That does certainly not seem to be correct. Is there really a
$ENV{"SITE_ROOT"} variable? And using backslashes within doublequotes
does likely result in something else but what you expect.

I would _guess_ that this is what you should have in mkttl.conf:

$const_database_path =
$ENV{DOCUMENT_ROOT} . '/mkttl_concept/databases/';

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      11-27-2003

(Topher) wrote:
> I'm not getting error messages, it's just not working - annoying as
> hell!


When you do start getting error messages, you may find the line

use CGI::Carp qw/fatalsToBrowser/;

at the top useful.

Ben

--
I've seen things you people wouldn't believe: attack ships on fire off the
shoulder of Orion; I've watched C-beams glitter in the darkness near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die. |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|
 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      11-27-2003
(Topher) wrote in message news:< om>...
> Hi,

............
> I'm not too hot on this Perl business and am basically winging it with

.....

Well I am not playing, but I have to say I find this game very
entertaining. It seems to be happening quite often that someone posts
a merest tease of a hint of what they are trying to do and some
incomprehensible garbled code and everyone tries to guess the task and
the existing errors and then write the code that they think might
address the problem.

I am quite genuinely in awe of the skilled players.

Steve
 
Reply With Quote
 
Topher
Guest
Posts: n/a
 
      11-28-2003
(Steve) wrote in message news:<. com>...
> (Topher) wrote in message news:< om>...
> > Hi,

> ...........
> > I'm not too hot on this Perl business and am basically winging it with

> ....
>
> Well I am not playing, but I have to say I find this game very
> entertaining. It seems to be happening quite often that someone posts
> a merest tease of a hint of what they are trying to do and some
> incomprehensible garbled code and everyone tries to guess the task and
> the existing errors and then write the code that they think might
> address the problem.
>
> I am quite genuinely in awe of the skilled players.
>
> Steve


Thanks people who have tried to help. I feel stupid to have forgotten
the die statement now!

Steve, you will notice at the bottom of my post 'Thanks very much, if
you need any more info please ask', since I wasn't sure what other
information I should give.
 
Reply With Quote
 
Chris Mattern
Guest
Posts: n/a
 
      11-28-2003
Topher wrote:
> (Steve) wrote in message news:<. com>...
>
>> (Topher) wrote in message news:< om>...
>>
>>>Hi,

>>
>> ...........
>>
>>>I'm not too hot on this Perl business and am basically winging it with

>>
>>....
>>
>>Well I am not playing, but I have to say I find this game very
>>entertaining. It seems to be happening quite often that someone posts
>>a merest tease of a hint of what they are trying to do and some
>>incomprehensible garbled code and everyone tries to guess the task and
>>the existing errors and then write the code that they think might
>>address the problem.
>>
>>I am quite genuinely in awe of the skilled players.
>>
>>Steve

>
>
> Thanks people who have tried to help. I feel stupid to have forgotten
> the die statement now!
>
> Steve, you will notice at the bottom of my post 'Thanks very much, if
> you need any more info please ask', since I wasn't sure what other
> information I should give.


If you read the guidelines, you'd *know* what info to give. Generally, you
should give an example Perl program that is as small as you can make it but
still produces the problem, what you expect this program to do, and what is
*does* do instead.

Chris Mattern

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Unable to run sample code from DBD::DBM on Strawberry Perl jl_post@hotmail.com Perl Misc 4 02-26-2010 09:40 PM
How to stop DBM/Perl crashing servers? OttawaTrade Perl Misc 9 09-13-2005 08:37 PM
storing a hash of a hash in a DBM database Colvin Perl Misc 3 12-30-2003 04:38 PM
dbm file locking with different versions of perl Matt Johnson Perl 0 08-08-2003 11:58 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57