I am trying to process the results of a survey. I load the current results from an XML file, update them, then write them back to the file. I am get a 500 Internal Server Error when I run it from a browser, but it works fine in Windows and Linux on the command line.

If you see anything that might be causing this problem, please let me know.

#! /usr/bin/perl
use XML::Simple;
use CGI ":standard";

$query = "when=Mar&otherWhen=ignore&talks=history&otherTalks=ignore&active=teachers&otherActivities=ignore" . 		

$data = new XML::Simple(KeyAttr => {question => 'name', a => 'name'})->XMLin('survey.xml');

#Parses the query string and updates the hash.
foreach $pair ( split('&', $query) )
	($q, $a) = split('=', $pair);
	next if $a eq "ignore";
	if ($q =~ /^other|comments/)
		open (other, ">>$q.txt");
		print other $a, "\n\n";

#Outputs the page.
print header(-type=>'text/html');
print start_html;
print h1("Survey Successful!!"), "\n";
print end_html, "\n";

#Outputs to the file.
$output = new XML::Simple(RootName => 'maa_survey')->XMLout($data);
open (out, ">survey.xml");
print out $output;

And yes, all the file IO works.

Look for what 'error.log' says, logged by the web server to actually see what went wrong. You can find this file somewhere under directory tree of web server installation.

Also you can add

use warnings;
use CGI::Carp qw(fatalsToBrowser);

for making perl errors to appear on the browser.


Turns out the problem was the colons. Colons aren't allowed in file names.

Silly me....

This question has already been answered. Start a new discussion instead.