Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

XML::Simple error in compiled script

by Smaug (Pilgrim)
on Mar 01, 2005 at 06:23 UTC ( [id://435292]=perlquestion: print w/replies, xml ) Need Help??

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

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/ 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.
I have noticed that this does not happen XML::Simple 2.09. I am running ActiveState Perl with XML::Simple 2.12.

Replies are listed 'Best First'.
Re: XML::Simple error in compiled script
by Anonymous Monk on Mar 02, 2005 at 15:40 UTC
    Try adding
    #perl2exe_include XML::Parser::Style::Tree
    and see if that fixes it. Using ASPN Perls "perlapp" with

    C:\>perlapp -add XML::Parser::Style::Tree

    fixed exactly the same problem I had just now.

    If anything it is dependant on the XML::Parser version, not the XML::Simple version.

      Thanks, that has changed the error at least. It now displayes:
      "Use of uninitialized value in pattern match (m//) at PERL2EXE_STORAGE/"
      Any help would be great!!
Re: XML::Simple error in compiled script
by Scrat (Monk) on Sep 10, 2007 at 13:43 UTC

    Resolution to the problem:

    Add the following code to the start of your script and compile it again:

    #perl2exe_include "XML/Parser/Style/"; #perl2exe_include utf8; #perl2exe_include "unicore/lib/gc_sc/"; #perl2exe_include "unicore/lib/gc_sc/"; #perl2exe_include "unicore/lib/gc_sc/"; #perl2exe_include "unicore/To/"; #perl2exe_include "unicore/To/"; #perl2exe_include "unicore/To/"; #perl2exe_include "unicore/To/"; #perl2exe_include "unicore/To/";



      Thanks Scrat that worked a treat!
      Peddle faster monkeys!! I need more power!!
Re: XML::Simple error in compiled script
by Anonymous Monk on Jan 30, 2008 at 09:47 UTC
    This solution helped me enormously: throughout a script, conversion to lower case (lc) worked absolutely fine, but in just one location it threw errors ("panic ..." etc. Thank you perlmonks! apb

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://435292]
Approved by AcidHawk
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-13 06:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found