develooper Front page | perl.qa | Postings from September 2010

Devel::Cover clobbers $ENV{PWD}, workaround?

Thread Next
From:
yary
Date:
September 24, 2010 17:00
Subject:
Devel::Cover clobbers $ENV{PWD}, workaround?
Message ID:
AANLkTi=xttUaBRFBixg=K4sC=-aDub3nvXJ-BFpteRV1@mail.gmail.com
I decided to check out the coverage of a little program and am running
into a bump. The code is part of a suite of code which uses the
environment to pass options. One of those environment variables
happens to be called PWD, and it doesn't hold the present working
directory. (It stands for "Period, Week, Day" and since this suite is
on windows, PWD had no definition in its shell beforehand.)

The problem is, when I run my script with "perl -MDevel::Cover
mycode.pl", Devel::Cover seems to overwrite $ENV{PWD} with the current
directory.

It's easy to show-

> cat > foo.pl
#!/usr/bin/perl

print "ENV{PWD}=$ENV{PWD}\n";

> set PWD='xyz'
> foo.pl
ENV{PWD}=xyz
> perl -MDevel::Cover foo.pl
(... Devel::Cover stuff...)
ENV{PWD}=D:/home/yhluc00/bin/
(... Devel::Cover stuff...)


Is there a workaround where my code can get the original $Env{PWD}? I
can change the test scripts, but I don't "own" all the code in the
suite that uses $ENV{PWD}.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About