Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

You got it, I cant see what i did wrong. I have been programming CGI scripts in C for a few years. Then all of a sudden the rug was pulled out from under me and i am forced to use perl because of the new servers. I would like help fixing a small problem i am having.The program is at most 20 lines. I broke it off from the main program to try and isolate the problem and i have. To put it better, i am too stupid to see what i skrewed up and i would like some one to post and say "YOU MORON! THIS IS WHAT YOU DID!". I can normally fix it if i can find it. I feel ashamed because i have to translate the simplese scripts from C into perl and im failing. ={ if anybody could take a look at it i would greatly appreciate it. I posted it in a text file for your reading pleasure. It is very small.
The part of the program im having problems with is at:
http://www.imbored.org/cgi-bin/problem.txt
The data file that it is reading is at:
http://www.imbored.org/cgi-bin/problemdata.txt

Replies are listed 'Best First'.
Re (tilly) 1: Help Me, I'm Blind!
by tilly (Archbishop) on Mar 24, 2001 at 20:35 UTC
    Your immediate problem in your program is almost certainly that your data has rows with many fields, but you are checking for equality with a string with 2 fields. That is never going to work, perhaps you meant to call index instead?

    However aside from the immediate problem, you have others. For instance your data format is very fragile, and your file-locking is definitely not working like you think it is. (When you close the file you lose the lock, then someone else can arrive and read the lock while you figure out what to write, then you write, then they write and your write was lost. Under load you will constantly lose votes.)

    I suggest switching to locking a sentinel file to solve your locking problem, or else switching to a database to solve both your locking mistakes and your data format fragility.

Re: Help Me, I'm Blind!
by Anonymous Monk on Mar 24, 2001 at 21:58 UTC
    there is no error. the problem must be logic based (probablly because im using the wrong command to do what i want to do) The major problem im running into is the fact that after reading in the data, everything goes perfectly but as soon as it gets to the second record the data dissapears and all variables go blank.
Re: Help Me, I'm Blind!
by voyager (Friar) on Mar 24, 2001 at 19:53 UTC
    What was the error message? Did anything make it to the browser? More likely you need to look in the server error log.