This is a very large program (5000 lines), but here are some snippets :
#!/usr/bin/perl
# CVS version : $Id: MiraLoader.pl,v 2.13 2008-02-03 15:11:46 efs Exp
+$
use strict "vars";
use warnings;
use FindBin qw($Bin);
use lib "$Bin/../lib";
use File::Basename;
use File::Copy;
use Getopt::Std;
use Encode;
use XML::Simple;
#$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
#[...]
log_msg(0,"Going to parse INI file.");
$INITBL = parse_INI("$MYTOPDIR/$MYINI",$SVCNAME); # $INITBL = ref
+ to Parameter table
# parse_INI dies in case of errors, so if we're here, it's ok
log_msg(0,"INI file parsed.");
#[...]
sub parse_INI {
#############
my $IniFile = shift; # INI file name
my $MYTAG = shift; # tag of "my" section
my $IniRef; # the returned ref.
my ($MIRA,$MYSECT);
my $SectRef;
my ($Val,@SplitVals);
my $Msg = "Required directory not found or insufficient permissions :
+";
my $MsgSect = "Required section missing in INI file :";
my $MsgFil = "Required directory/file not found or insufficient permis
+sions";
my $MsgParam = "Required parameter missing in INI file :";
my $MsgParam2 = "Parameter in INI file has invalid value :";
my $fh;
log_msg(0,"==>parse_INI()") if $Debug>1;
unless (open($fh,'<',$IniFile)) {
die_msg(0,"** Cannot open INI file \"$IniFile\" **") if $Debug
+;
}
# Create an XML::Simple object with default parameters,
my $XMLOBJ = new XML::Simple(
keeproot => 1,
forcearray => 0,
# keyattr => 'Id',
forcecontent => 1,
contentkey => 'Value',
);
$IniRef = $XMLOBJ->XMLin($fh); # ***
close $fh;
#[...]
}
As far as I can tell, it crashes with the error on the line marked "***" above.
But I have 3 other programs, which do just about the same as above, and which do not experience this problem.
With the line
$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
commented out as above, the message is :
read error at C:/Perl/lib/XML/Parser/Expat.pm line 469
With the same line set to :
$XML::Simple::PREFERRED_PARSER = 'XML::SAX::ExpatXS';
then the error message is :
read error at C:/Perl/site/lib/XML/SAX/ExpatXS.pm line 163
I thus assume it must be some cause common to both parsers, and external to the parser itself. But why then do other programs running on the same XP machine and using exactly the same logic and parser, parsing the same XML file, not crash, and why does this one crash only when run as a service, and not in a console (running under the same non LocalSystem user-id in both console and service mode?
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.