Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: pp (PAR-Packer) - how to access included data files

by swl (Prior)
on Nov 06, 2022 at 21:35 UTC ( [id://11148014]=note: print w/replies, xml ) Need Help??


in reply to pp (PAR-Packer) - how to access included data files

The post linked to by marto has a good example of checking if running under PAR and then accessing the file accordingly.

More details about the environment variables used by PAR can be seen at https://metacpan.org/dist/PAR/view/lib/PAR/Environment.pod.

  • Comment on Re: pp (PAR-Packer) - how to access included data files

Replies are listed 'Best First'.
Re^2: pp (PAR-Packer) - how to access included data files
by ibm1620 (Hermit) on Nov 07, 2022 at 00:14 UTC
    I wasn't really clear about the use of PAR_TEMP, given the advice not to use it in https://metacpan.org/dist/PAR/view/lib/PAR/Environment.pod .

    I finally figured out that "/", which the doc says is the root under which included files are stored, could be computed at runtime by dirname($ENV{PAR_0}) . "/inc".

      dirname($ENV{PAR_0}) . "/inc".

      Why you want to go low level when you have this? :

      # PAR::read_file() returns a file inside any loaded PARs my $conf = PAR::read_file('data/MyConfig.yaml');

      (from SYNOPSIS)

        I must have overlooked read_file(). Thanks.

        In my case, the easiest approach was to doctor the @ARGV before processing it, as follows:

        if (exists $ENV{PAR_TEMP}){ # running via PAR/pp push @ARGV, "$ENV{PAR_TEMP}/inc/lex.dict"; }

      The docs could be a bit clearer but my reading is that PAR_TEMP should not be assigned to but is fine to read from.

      Your approach will still work, though.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2025-05-22 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.