To access a directory using a relative path, you need to establish first what that path will be relative to. That means you need to find out what the current working directory is for running CGI scripts.
If you add this program to your server and call it up on a browser you will see the current working directory that that server applies to all of its CGI programs.
use strict;
use warnings;
use CGI ':standard';
use Cwd 'getcwd';
print header('text/plain');
printf "Current working directory: %s\n", getcwd;
If, for instance, you find that the current working directory is /main/site
then you can create the file using the path ../logs/mylog.log
.