Hello esteemed monks
I have a scripts which reads in it's configuration from an XML file. If I run the script as the .pl file all is well. However after compiling the file with Perl2Exe I get a strange error in the XML::Simple module.
I'm not sure how I've broken it.....
Here it a scaled down version of what I do:
use strict;
use warnings;
use XML::Simple;
&Getsettings;
sub Getsettings {
if (my $config = XMLin("xmlin.xml",ForceArray => 1)) {
my $value1 = $config->{'value1'}->[0];
my $value2 = $config->{'value2'}->[0];
my $value3 = $config->{'value3'}->[0];
print "The values of 1, 2 and 3 are: $value1 $value2 $value3\n
+";
}
else {
print "Config file not found";
}
}
and here is the XML file
<XML>
<value1>1</value1>
<value2>2</value2>
<value3>3</value3>
<value4>4</value4>
</XML>
As stated it runs fine as a .pl but gives the error: "Can't use string ("1") as an ARRAY ref while "strict refs" in use at PERL2EXE_STORAGE/XML/Simple.pm line 231."
I have looked at line 231 in the module and it seems that it is expecting a reference which I am obviously not sending.
1. Can somebody please explain what I have done wrong?
2. Can somebody also explain why it only happens in the compiled script.
Thank you oh nobel Monks.
UPDATE:
I have noticed that this does not happen XML::Simple 2.09. I am running ActiveState Perl 5.8.6.811 with XML::Simple 2.12.
Thanks.
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.