http://www.perlmonks.org?node_id=1018457

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

Hello Monks

I have a script in which I use Cwd to get the current directory (getcwd) and then open a file in that directory.

This seems to work fine when running under perl. But when I use pp on it to package it so it can run independently, it returns the message ' no such file or directory' when trying to create the file that worked before.

Is it expected for par to bring in differences, or is there something obvios I'm overlooking?

Thanks for your time

MorayJ

Replies are listed 'Best First'.
Re: Script error after PAR
by Anonymous Monk on Feb 13, 2013 at 08:09 UTC

    Is it expected for par to bring in differences, or is there something obvios I'm overlooking?

    Yes, par brings in a different environment,

    Yes, you're overlooking something obvious :)

      Hmmmm, ok. I've done a couple of other scripts using PAR/pp and they have worked as they did pre-executable.

      Would you be kind enough to point out what I am missing? I can't see anything about having to make changes to a script to make it suitable so don't know where to look.

      Thanks

Re: Script error after PAR
by MorayJ (Beadle) on Feb 13, 2013 at 20:12 UTC

    Me again!

    Right, I didn't really give enough information here, but it looks like the problem was that opening a file with >:encoding(utf8) just works when run through the perl interpreter.

    You need to have use Encoding in the script for par to work with it.

    Cheers

    MorayJ

      Indeed, I didn't!

      Thanks for the tip.