Hello all, A friend of mine (no really! It's not me!) inherited this ancient (15 year old) Perl script that isn't working for some reason. The script takes the output of an HTML form and puts it into a .dat text file, formatted all nice and neat for him to read. It also appends to this same .dat file whenever there is a submission. At least that's what it's supposed to do. Using my rudimentary perl skills, I think I've narrowed down the problem to this section: $FP_RECORD=" Submitted On: $Date\nOwner's Name:$Name Team Name:$Team_Name Team #:$TeamN\nLeague Name:$League Week #:$WeekN\n\nLINE ONE\n1.$l1f1 2.$l1f2 3.$l1f3\n1.$l1d1 2.$l1d2\n \nLINE TWO\n1.$l2f1 2.$l2f2 3.$l2f3\n1.$l2d1 2.$l2d2\n\nLINE THREE\n1.$l3f1 2.$l3f2 3.$l3f3\n1.$l3d1 2.$l3d2\n\nALTERNATE FORWARDS\n1.$altf1 2.$altf2 3.$altf3 4.$altf4\n5.$altf5 6.$altf6 7.$altf7 8.$altf8 9.$altf9 \n\nALTERNATE DEFENSEMAN\n1.$altd1 2.$altd2 3.$altd3\n4.$altd4 5.$altd5 6.$altd6\n\nGOALTENDERS\n1.$g1 $one $two $three\n2.$g2 $four $five\n3.$g3 $six $seven\n4.$g4 $eight\n5.$g5 $nine\n\nALTERNATE GOALTENDERS\n1.$altg1 2.$altg2 3.$altg3\n\nFREE AGENTS ROUND #1 \n1. Pick Up:$apick1\n2. Pick Up:$apick2\n3. Pick Up:$apick3\n4. Pick Up:$apick4\n5. Pick Up:$apick5\n6. Pick Up:$apick6\n7. Pick Up:$apick7\n8. Pick Up:$apick8\n9. Pick Up:$apick9\nDrop: $adrop2\nFREE AGENTS ROUND #2 \n1. Pick Up:$bpick1\n2. Pick Up:$bpick2\n3. Pick Up:$bpick3\n4. Pick Up:$bpick4\n5. Pick Up:$bpick5\n6. Pick Up:$bpick6\n7. Pick Up:$bpick7\n8. Pick Up:$bpick8\n9. Pick Up:$bpick9\nDrop2: $badrop2\n\nTRADES\nWe Trade 1.$wt1 \nTo Team #:$t1 We Receive: $wr1\nWe Trade 2.$wt2 \nTo Team #:$t2 We Receive: $wr2\nWe Trade 3.$wt3 \nTo Team #:$t3 We Receive: $wr3\nWe Trade 4.$wt4 \nTo Team #:$t4 We Receive: $wr4\nWe Trade 5.$wt5 \nTo Team #:$t5 We Receive: $wr5\nWe Trade 6.$wt6 \nTo Team #:$t6 We Receive: $wr6\nWe Trade 7.$wt7 \nTo Team #:$t7 We Receive: $wr7\nWe Trade 8.$wt8 \nTo Team #:$t8 We Receive: $wr8\nWe Trade 9.$wt9 \nTo Team #:$t9 We Receive: $wr9\nWe Trade 10.$wt10 \nTo Team #:$t10 We Receive: $wr10\nMisc. Notes and Comments:\n$misc\n-----------------------------------------------------------------------"; format FP_LOGOUTPUT = @* $FP_RECORD . open (FP_LOGOUTPUT, ">>/path/to/html/logs/hockey_2011.out"); &open (FP_LOGOUTPUT, ">>/path/to/html/data/hockey_2011.dat"); write(FP_LOGOUTPUT); close(FP_LOGOUTPUT); Code (markup): As you may be able to tell, the form and script is for a fantasy hockey league. A couple of notes: Using the code as-is gives me a 500 Internal Server error. So I removed the ampersand (&) from the second open statement. This fixes the error and brings the submitter to the generated HTML page confirming the submission was successful. Now for the part that I can't figure out. When I open up the hockey_2011.dat file, it contains a single line: $FP_RECORD and nothing else. If I submit the form again, it appends another $FP_RECORD to the file, so that it looks like this: $FP_RECORD $FP_RECORD and again, nothing else. So I'm guessing that $FP_RECORD is supposed to hold the form data, but instead it's just updating the .dat file as if $FP_RECORD was just a string and not a variable. Anybody have any ideas why that is? I've been staring at this thing for days, and have no clue. Any help would be appreciated. Thanks, Mike
Hmm... I guess no one really uses Perl on this forum. This script has officially kicked my butt. I'm ready to give up on it.
I believe the extra blank lines in your format command are causing this. Change this part: format FP_LOGOUTPUT = @* $FP_RECORD . Code (markup): to this: format FP_LOGOUTPUT = @* $FP_RECORD . Code (markup): No code has changed, just remove the extra blank lines. That should do the trick.
Genius! +1000 internets to you. I can't believe it was that simple. Thank you so, so much! This thing has been killing me for over a week. I would never imagine it was the whitespace causing the issue. Why is that, do you know? This script ran fine on my friend's server at some point, so I don't know why removing the whitespace did it, but it worked!!!