Ubuntu 14.04 - cgi-script isn't getting the correct working directory

I have a virtual server with the normal configuration of a cgi-bin direcotry under /home/jim. If I execute a small perl program in that directory that prints the working directory such as

my $path = getcwd();
print header;
print start_html();
print “CWD=$path

And call it via http:///cgi-bin/print.cgi
It prints

If I move the script to /usr/lib/cgi-bin
and call it via

It prints


You can imagine what happens with a complex program that’s trying to load modules from thw current working directory. I know how to fix it from within a script but I don’t think it should behave differently from a virtual server. It works OK on a Centos 6 system.

The environment variables all see to know where the script is. For instance

Any ideas?