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

I am starting to goof around with XML::RSS so i made a simple little program. It runs perfectly from the command line, but it just hangs if i try to run it from apache. Evidentally its not liking the parsefile(). Does anyone have any ideas whats going on with it? Thanks!!
use strict; use LWP::Simple; use XML::RSS; use CGI; $|++; my $cgi = new CGI; print $cgi->header,$cgi->start_html('INFO PORTAL'); my $rss=new XML::RSS; my $FILE="/home/foo/slashdot.rdf"; mirror("http://slashdot.org/slashdot.rdf", $FILE); $rss->parsefile($FILE); my $item; for $item (@{$rss->{"items"}}) { print "<A HREF=\"$item->{link}\">$item->{title}</A><BR>"; } print "HERE NO PROBLEM!!<BR>"; print $cgi->end_html;

Replies are listed 'Best First'.
Re: XML::RSS choking on the webserver
by Joost (Canon) on Jan 28, 2003 at 14:23 UTC
    My first guess would be that your webserver has no permissions to open the file. See also the idiots guide to perl/CGI problems.

    Evidentally its not liking the parsefile
    Evidently you also get some error message. It might help to tell us what it is :-)

    -- Joost downtime n. The period during which a system is error-free and immune from user input.
Re: XML::RSS choking on the webserver
by peregrine (Acolyte) on Jan 28, 2003 at 15:49 UTC
    I also believe its a permissions issue. If you look in the error log for apache, you'll probably find some kind of message stating that it couldn't open /home/foo/slashdot.rdf.

    I've tried to reproduce your test, and what happened is that the mirror command silently failed, so that there was nothing left to parse. No error was returned to the browser, so it looks like a parse failure. Always check the error log when perl scripts start misbehaving :)

    Solution: you'll have to make the script save the rdf file in some other directory. This directory must be writable by the user that the web server runs as (check for the User option in the httpd.conf file). If you're just playing around, you could use /tmp, but not for anything more serious than that. I always use a dedicated directory.

    If the error message is different, post that and it will explain whats going on.