Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: "PAR'ing" XML configs?

by rinceWind (Monsignor)
on Aug 08, 2005 at 15:31 UTC ( [id://481914]=note: print w/replies, xml ) Need Help??


in reply to "PAR'ing" XML configs?

You need to use the -a option to pp.

     -a, --addfile=FILE|DIR
         Add an extra file into the package.  If the file is a
         directory, recursively add all files inside that
         directory, with links turned into actual files.

         By default, files are placed under "/" inside the
         package with their original names.  You may override
         this by appending the target filename after a ";", like
         this:

             % pp -a "old_filename.txt;new_filename.txt"
             % pp -a "old_dirname;new_dirname"

         You may specify "-a" multiple times.

--

Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)

Replies are listed 'Best First'.
Re^2: "PAR'ing" XML configs?
by davidrw (Prior) on Aug 08, 2005 at 15:45 UTC
    Yes, but what OP needs is a way then, from the perl script, to know where the included file is in order to read it. This part of the FAQ led me to look at $ENV{PAR_TEMP} and see what the directory structure was and where the added test.txt was placed.
    # pp -o a.exe -a test.txt test.pl #test.pl: open FILE, $ENV{PAR_TEMP} . "/inc/" . "test.txt"; while(<FILE>){ print; } close FILE;

      That's it. Thanks!

      Everything is extraced under the $ENV{PAR_TEMP}/inc/. I was able to successfully create a test script using the following:

      test.xml
      <opt date="test> <test>This is a test</test> <company id="test" /> </opt>
      test.pl
      #!/usr/bin/perl use strict; use XML::Simple; use Data::Dumper; my $xml = new XML::Simple; my $ret = $xml->($ENV{'PAR_TEMP'} . "/inc/test.xml"); print Dumper($ret);
      Compiled with: pp -o test.exe -a test.xml test.pl

      Moved the PAR package to another directory and ran it. It ran successfully.

      I guess for testing, one can check to see if PAR_TEMP is set. If it's not, assume a command line run else assume PAR run, since the PATH to your file will definatly be different based on a PAR or command line run.

      -- philip
      We put the 'K' in kwality!

Re^2: "PAR'ing" XML configs?
by guice (Scribe) on Aug 08, 2005 at 15:44 UTC

    Nice! Then do I access the file like I normally would: $xml=XMLin("config.xml")? Or do I access it via "/config.xml"?

    Thanks again though, this is one step I needed, which I actually forgot about. The problem I was facing was referencing the file...

    -- philip
    We put the 'K' in kwality!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://481914]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-18 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found