develooper Front page | perl.beginners | Postings from February 2002

Cwd behavior when $PATH is not there - bug or feature?

Adriano Rodrigues Ferreira
February 21, 2002 19:14
Cwd behavior when $PATH is not there - bug or feature?
Message ID:

I have encountered a behavior that I think it is a little
odd and I have discovered it has to do with the standard
module Cwd. I had a Perl script which was called by
a Java application via Runtime.getRuntime().exec()

I have discovered that it was a good idea to use the
form that includes not only the name of the command
(in the case, something like "c:\perl\bin\perl.exe")
but also some minimum of the environment.
The application used to stop complaining about Cwd
which could not split an undefined object in line 103
(I'm using Windoze 2000, ActivePerl 5.6.1)
This line reads as

if($^O eq 'MacOS' || grep { -x "$_/pwd" } split(':', $ENV{PATH})) {

The point is that the Java application called the Perl interpreter
with no value for $PATH environment variable and this
caused Cwd to die.

I don't think this is desirable. A simple modification in the Cwd
would check for the defineteness of $ENV{PATH} before
accessing it.

What do you think?


Adriano. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About