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

I have a script sysmon.pl

It gets xml data from a website and parses it

Running it as a .pl file it works perfectly

If I compile it using pp I get the error: Could not find sysmon.xml in U:\Projects\Sugar\utils\ at script/sysmon.pl line 7 9.

My code at line 79 is:

my $edata = XMLin( $xdata, KeyAttr => { workstation => 'name' } );

Any idea what I can do to fix it

Replies are listed 'Best First'.
Re: problem using pp with XML::Simple
by davido (Cardinal) on Dec 13, 2012 at 17:37 UTC

    $xdata probably contains the filename, "U:\Projects\sugar\Utils\sysmon.xml". Your script may not have read-access to that path. That's just one possibility. What happens if you try to open the file? I suspect that the open will also fail, but if you check the error message (in $!) you might get a more revealing explanation.


    Dave

Re: problem using pp with XML::Simple
by dasgar (Priest) on Dec 13, 2012 at 18:57 UTC

    Does the XML file exist when you run pp to create the executable? If not, try making sure that the file exists in that location with that file name even if it is an empty file.

    Basically, I'm guessing the XML file doesn't exist until the script downloads it and the script deletes it after parsing it. If that's the case, them the pp utility is trying to locate a file that doesn't exist.

Re: problem using pp with XML::Simple
by mikesolomon (Novice) on Dec 17, 2012 at 09:47 UTC

    Further investigation shows the issue isn't with XML::Simple

    I am pulling data from the web using LWP::Simple

    When I run the compiled version no data is returned

    Testing a bit more I found it works fine with http but not with https :(

    My test code is

    use LWP::Simple; use Encode::Byte; my $url = 'https://msp.f-secure.com/web-test/common/test.html'; my $data = LWP::Simple::get($url); print $data;

    running normally works fine but if I compile it using pp no data is returned

Re: problem using pp with XML::Simple
by Anonymous Monk on Dec 14, 2012 at 08:39 UTC

    Hire a programmer :)

    Seriously sysmon.pl doesn't use XMLin :P

    Hmm, a program is trying to read a file that doesn't exist, how to fix .... all joking aside, somebody is going to have to do some programming