Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Par::Packer and paths

by Anonymous Monk
on Oct 27, 2011 at 18:39 UTC ( [id://934212]=note: print w/replies, xml ) Need Help??

in reply to Par::Packer and paths

How to reference a file included with --addfile myfile.txt option?

Exactly as documented, PAR::read_file , example Re^4: introspection, or running pod2html on itself

However, how can I make access to that file universal from both EXE and when running the script through the Perl interpreter (perl myfile.txt) ?

Through abstraction, naturally :)

sub GimmeFile { if( $ENV{PAR} ){ PAR::read_file( shift ) } else { File::Slurp::read_file( shift ); } }

...pwd... How can I reconcile that?

pp'ed programs do have the correct pwd, so what you're saying makes no sense

Maybe you wish to not rely on pwd, but chdir to where you wish to be?

or use GimmeFile above? Or maybe File::ShareDir::PAR?

Replies are listed 'Best First'.
Re^2: Par::Packer and paths
by gri6507 (Deacon) on Oct 27, 2011 at 18:51 UTC
    Thank you for the response. With regards to my first question, your solution is ideal. I did not know that that environment variable. Just a slight correction: the actual variable is $ENV{PAR_0}.

    I have to retract my second question. This was a user error. Near the top of my script I had a chdir($ENV{PAR_TEMP}) that I forgot about. That is why it appeared that my pwd was a PAR directory. Sorry about that.

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-06-19 10:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.