big_chat.pl is running on the server and doesn't care about relative paths with respect to the webserver. You are dealing with the server's filesystem at this point, so editing those other files is a matter of knowing what folders they are in. You could simply reference them as absolute paths.
$textdir = "/data/text";
$docfile = "/htdocs/cowboys/$FORM{'3'}";