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

I had been having trouble gettng CGI.pm to recognize POSTed params under mod_perl. After much commenting of code, it appears the culprit is XML::Simple.

If you run the following (stripped down to show problem) script under normal cgi, and click the button, things work fine and you can see the form parameters (I Dump $q for convenience; in practice, I use $q->param()).

But if you run under mod_perl you don't see any POSTed params, although any in the query string do show.

Commenting out the "use XML::Simple", and all is well under mod_perl. Is there something else I'm missing or is XML::Simple doing something unexpected? Note that you don't even have to call any XML::Simple methods, just "use" it, to make this problem show up.

#! /perl/bin/perl -w use strict; use CGI; use Data::Dumper; use XML::Simple; print "Content-type: text/html\n\n"; print "<BODY><HTML>"; print '<h1>testing</h1>'; my $q = CGI::new; print "<pre>" . Dumper($q) . '</pre>'; print qq[ <form method=post > fld1 <input name=fld1 > <br>fld2 <input name=fld2> <br><input type=submit name=btn_submit value="submit"> </form> ]; print '</body></html>';

Replies are listed 'Best First'.
Re: XML::Simple.pm breaks CGI.pm under mod_perl?
by mirod (Canon) on Jun 18, 2001 at 21:51 UTC

    Which version of XML::Parser (not XML::Simple) are you using?

    If you are using a version before 2.30 then that could be the cause of the problem, although usually it generates a segfault when you run Apache.

      I am running version 2.27 of XML::Parser on Win32.

      At ActiveState, XML::Parser isn't in the package list, and when I run verify from PPM it tells me I am up to date.

      Does that mean that 2.30 isn't available for Win32 yet?

Re: XML::Simple.pm breaks CGI.pm under mod_perl?
by Hero Zzyzzx (Curate) on Jun 18, 2001 at 22:06 UTC

    You aren't perchance using Nusphere? I had an issue with mod_perl not recognizing POSTed params, and it turned out it was a bug, related to how mod_perl and apache were built. Upgrading my version of NuSphere fixed it.

      I am not running Nusphere.

      I neglected to mention I am on Win32 and using binary distributions of Perl (5.6), Apache (1.3.17) and mod_perl.

Re: XML::Simple.pm breaks CGI.pm under mod_perl?
by voyager (Friar) on Jun 19, 2001 at 01:04 UTC
    Update: I replaced the code using XML::Simple with XML::Parser and the problem went away. This doesn't prove that the problem isn't ultimately caused by (the verion of) XML::Parser, but at least in my case it required the interaction of XML::Simple to make the POSTed variables not show up.

    As a side note, while I was initially satisfied with XML::Simple, I soon found that coding the handlers for XML::Parser was no more trouble than using XML::Simple ... at least if you have the case where you may have 0, 1, >1 of a tag type. Cuz then you've gotta start telling XML::Simple about array folding, key tag lists, etc.