I don't know what the specific problem is, but here are a few suggestions that may help you find out.
- Are you using strict? I notice a few variables, like $builddir, $dir and $fname that don't have a declared scope.
- In your for loop, you should scope $dir and $fname to the inside of the loop (with my) so you can be sure that they get re-defined each time through. Also, try printing them to STDERR (under CGI it will go to the error log) so you can make sure they are what you think they are.
- Check the return value from chdir. Like open, it will return false and set $! upon failure. It may be that your web server user doesn't have permission to enter the directory.
- Don't use all those crazy backslashes inside double-quoted-strings. They make your pathnames very confusing. Instead, use single-quoted strings, e.g.
$ENV{'SSDIR'} = '\chinook\Sourcesafe\Acme';
That should set you on the right track.