I beg the indulgence of the Monks. I posted this last week under the heading of
XML::Twig->parse() error under CGI and I am resubmitting this issue under
the above heading to provide some additional data, and to see if we can have another
look at this issue. As
mirod has pointed out, XML::Twig is not involved with the
problem that I am having except as a messenger of the bad news.
The Situation:
I have written a module that reads in log files (which are in XML) and parses them
for various conditions to provide some reporting on my EAI engine (all Perl, all the time).
The package uses mirod's XML::Twig to set up handlers for different conditions to
report on, and I use it to create a web page that our users can view to see errors and
successes, and to post-process the results.
After I developed the module I tested it
with a script and everything works just fine. When I call the same package from a CGI program
I get an error from XML::Expat
The Problem:
Here is the error message that I am getting from XML::Expat:
Can't use string ('<myXMLString><myElement name="foo"-') as a
symbol ref while "strict refs" in use at
.../perl5/site_perl/5.6.0/sun4-solaris-thread/XML/Parser/Expat.pm
line 456.
If you look at the code at that point, you will see the following:
sub parse {
my $self = shift;
my $arg = shift;
croak "Parse already in progress (Expat)" if $self->{_State_};
$self->{_State_} = 1;
my $parser = $self->{Parser};
my $ioref;
my $result = 0;
if (defined $arg) {
if (ref($arg) and UNIVERSAL::isa($arg, 'IO::Handle')) {
$ioref = $arg;
} elsif (tied($arg)) {
my $class = ref($arg);
no strict 'refs';
$ioref = $arg if defined &{"${class}::TIEHANDLE"};
}
else {
eval {
$ioref = *{$arg}{IO}; # This is line 456
};
undef $@;
}
}
So the offending line is where "$ioref = *{$arg}{IO};". In this case, $arg happens to be my
XML string, which is the correct thing for it to be. If you push the scripty version of this
though the debugger, all values appear correct, and the globbing works fine under use strict.
My thoughts:
- Some have suggested that the version of XML::Expat is one that the web-server is
using, and is therefore different than my test script. I don't think that this is true,
due to the fact that the error message explicitly has the path of the version of Expat.pm
that I expect, and know is the right path.
- It is possible that the version of Perl is different on the command line that the one
the webserver calls, even though the include path is fine. Might this have an impact? If so
I can rebuild the Perl that Apache uses. Does the kerbang in my .pl have any bearing on
which Perl the webserver uses?
- I suppose I can take the "no strict 'refs';" line and copy it into the section in the
Expat.pm or move it up block-wise. I would like to avoid this, since when I move the code
into production, that could be a difficult luxury.
If anyone else has any ideas I would appreciate it. Thanks so much to those who have
already made suggestions.
Brian - a.k.a.
DrSax
Edited 2001-05-29 by Ovid
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.