At 12:43 PM 4/18/01 -0400, Kat wrote:
>*sigh*
>
>I have changed the script to include -w, but not strict.

Keep going :-)  Trust me, once you get used to putting use strict in your 
programs you will wonder how you ever got along without it.

>   HOWEVER, if I change the error routine to a "die "message $!" "  I do 
> not even get a STATUS??!?!  It is blank.

That suggests you're the victim of an error that doesn't set $!.  I know, 
that's kinda obvious.  From the DB_File source it appears that this could 
happen with some kind of failure with the file format itself, rather than 
the call to open it.  Although I would have expected a complaint to stderr.

>BUT, to make matters even more fun, if I DELETE  the existing db file and 
>then change the tie to include O_CREAT | O_RDWR, then it creates and empty 
>file!

That's what it's supposed to do.

>  I am pulling out my hair over this.

Ok.  My guess is, either you have a permissions problem with the existing 
db file, or that existing file is not in the right format.  Was it created 
on another machine or with another perl?

The default arguments are O_RDWR|O_CREAT, 0644, $DB_HASH.  So you might as 
well leave them out.

Can you create a DBM just so that you can see that you can read it in 
ok?  Can you do this:

$ perl -MDB_File -we 'tie %h, "DB_File", "test.db" or die $!; $h{key} = 
"value"'
$ perl -MDB_File -MData::Dumper -wle 'tie %h, "DB_File", "test.db" or die 
$!; print Dumper \%h'
$VAR1 = {
           'key' => 'value'
         };

>I just got done doing the following:
>
>updated db3 libs
>ran perl CPAN -e 'install Bundle::snapshot....."
>to re-install all libraries... No change.
>
>Back to the drawing board.
>
>I did get some email from another saying they cut and paste into another 
>screen and it worked, with the exception of errors at the end for the 
>undefined "error_routine"....
>
>
>
>At 09:22 AM 4/18/2001 -0700, Peter Scott wrote:
>>At 08:19 AM 4/18/01 -0400, Kat wrote:
>>>Ok, I have exhausted all other options.  This code used to work, and 
>>>now, no matter what I use for a path, I always get an error opening the 
>>>file... Does anyone see anything obvious here in this snippit??
>>
>>Not related to not being able to open the database.  What error are you 
>>getting?
>>Your script should use -w and "use strict".  There could be other 
>>problems in there you are not being told about that might cause your problem.
>>
>>>#!/usr/bin/perl
>>
>>Should be
>>#!/usr/bin/perl -w
>>use strict;
>>
>>>#This script will return quiz responses to a browser. It reads from a 
>>>quiz database file
>>>#which has a structure as follows:
>>>#Record Key = StudentID+StudentName+Department+Company+QuestionID
>>>#Record Value = StudentID, StudentName, Department, Company, QuestionID, 
>>>QuestionName, Chapter, Type, Answer, Grade, PageNumber, Weight, Tries
>>>#Field values are delimited by the | character.
>>>
>>>#Load the Database Module
>>>use Fcntl;
>>>use DB_File;
>>>
>>>#parse the response data
>>>&parse_form_data(*submit_data);
>>>
>>>$database = "/anthing I put here, whether valid or not, makes no 
>>>difference";
>>>
>>>
>>>for(0..255){
>>>         $escapes{chr($_)} = sprintf("%%%02X", $_);
>>>}
>>>
>>>#Open the database file and tie it to the %file variable
>>>tie(%file, "DB_File", $database, O_RDWR, 0644, $DB_HASH)
>>>   or &return_error (500, "Quiz Control File Error", "Failure-Could not 
>>> open quiz database!");
>>>
>>>#Get the Student Information to return scores for
>>>$query_ID = $submit_data{'StudentID'};
>>>$query_Name = $submit_data{'StudentName'};
>>>$query_Department = $submit_data{'Department'};
>>>$query_Company = $submit_data{'Company'};
>>>$query_Chapter = $submit_data{'Chapter'};
>>>$query_Title = $submit_data{'Title'};
>>>$query_ListTitle = $submit_data{'ListTitle'};
>>>$query_Prompt1 = $submit_data{'Prompt1'};
>>>$query_Prompt2 = $submit_data{'Prompt2'};
>>>$query_Prompt3 = $submit_data{'Prompt3'};
>>>$query_Prompt4 = $submit_data{'Prompt4'};
>>
>>--
>>Peter Scott
>>Pacific Systems Design Technologies

--
Peter Scott
Pacific Systems Design Technologies

Reply via email to