Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

XML::Simple and use lib

by BioHazard (Pilgrim)
on Aug 16, 2002 at 18:14 UTC ( #190721=perlquestion: print w/ replies, xml ) Need Help??
BioHazard has asked for the wisdom of the Perl Monks concerning the following question:

Hallo there, I've got the following problem: I'm using XML::Simple on my local Win32 machine and it works fine. When I upload scripts using XML::Simple on my webserver which runs on Linux, I have to include XML::Simple by using use lib "/path/modulesfolder/"; Also this is working very well.
But when I call XMLin(args); in my scripts, an Internal Server Error occurs. I have printed an HTML Header and have used a debugged script. As I mentioned above, the same script works fine on my local webserver. Also the shebang line is correct in the "Linux-Script". I'm sorry I do not have access to my error log files (apache). Maybe I should change the provider... I even read throug the Simple.pm but couldn't find a thing, which might be problematic with linux. A friend of mine told me, these modules are platform independent.
Has anyone an Idea what the cause of the problem is? Thanks a lot and sorry about my English

Comment on XML::Simple and use lib
Select or Download Code
Re: XML::Simple and use lib
by krisahoch (Deacon) on Aug 16, 2002 at 18:33 UTC

    BioHazard,
    With neither code nor logs, it is difficult to help you. I would suggest running your source file from the command line to see quickly what is going on. Running it from the command line will give you a better out put than Code 500.

    If you don't find anything that way then use the debugger. Failing that, request the Apache logs from your provider.

    You may also want to post your code here so that we can have a look at it. Someone here (probably Abigail-II) will know what is going on right away

    Kristofer

      Oh, sorry about that: Here's a piece of my code:

      #!/usr/bin/perl use strict; use lib "/www/htdocs/v028502/cgi-bin/Modules/"; use CGI; # does not need use lib use HTML::Template; # does need use lib and works fine use XML::Simple; # does need use lib but doesn't work correctly (XMLou +t() works) use LWP::Simple; # does need use lib and works fine, too. my $q = new CGI; my $name = $q->param('name'); $name = lc($name); my $xml = XMLin("$name.xml", searchpath => ['users']); # NOT possible +on the Linux machine! print $q->header('text/html'); # HTML Header print "$xml->{email}<br>$xml->{adress}"; # For Example... exit;
      I can not run my source file from the command line, because it is the machine of my ISP. On my local webserver it works absolutely fine, also in the command line. I even asked for the error logs, but they didn't send it to me yet.
      I hope I made my problem a bit more clear.

        Since you don't have access to logs or command line, here is what I would suggest. Change the line
        <i>my $xml = XMLin("$name.xml", searchpath => ['users']);</i>
        to...

        my $xml = XMLin("$name.xml", searchpath => ['users']); use Data::Dumper; print "<pre>" . Dumper($xml) . "</pre>";


        Then look for an element named 'adress'. I would assume you mean 'address' from the following line.
        <i>print $xml->{email}<br>$xml->{adress}</i>

        --Kristofer

        Updated: added code tags

        if you don't have access to your error logs and XMLin() seems to be where it's dieing, maybe try something like:

        print $q->header(); my $xml; eval { $xml = XMLin("$name.xml", searchpath => ['users']); }; if($@) { print "the error was: <pre>$@</pre>"; } else { print "no error was generated."; }

        anders pearson

Re: XML::Simple and use lib
by JupiterCrash (Monk) on Aug 16, 2002 at 19:04 UTC
    A shot in the dark, but what I would try:
    What if you start your program like this?
    BEGIN { push (@INC, "/www/htdocs/v028502/cgi-bin/Modules/"); }
    Maybe XML::Simple is itself looking for something in the directory you defined in the 'use lib' line? Try throwing that directory in the @INC too, can't hurt.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://190721]
Approved by IlyaM
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-12-29 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (187 votes), past polls