I'm having problems with my FFDB (flat file database). It writes to the database correctly from the form but I am having trouble getting my script to read the database and output the result. Here is the Perl source code I am using to attempt to read the data from the DB:
#!/usr/bin/perl -w
use strict;
open (INPUT, "file.txt") or die "Can't open data file: $!";
while (<INPUT>) {
chomp;
my @fields = split(/\|/, $_);
print "$fields[1], $fields[0]: $fields[2]\n";
}
close INPUT;
The PERL script didn't work as a separate file with the shebang, so I integrated the script into the one that handles the form input from the website. The format of the FFDB has all of the words delimited by the pipe character. The script:
- Opens the FFDB for reading
- Then it loops through the data
- For each line it should print out the different fields
Thus, once I hit the submit button on the website, I should see the words printed out for each field. I have tried taking the print command out and putting in the field scalars into the HTML and it doesn't show the field scalars. Instead I get:
Internal Server Error
If I look at my log files it shows a little more information:
premature end of script headers
How can I echo out or print this text on a web page?