in reply to perl & UNC paths

You need to check that chdir() is actually succeeding. Try this:

  chdir($outdir) or die "Unable to chdir to '$outdir': $!\n";

Most likely your first chdir() is failing.

-sam