in reply to opening a file using CGI

The most likely problem is that the web user (the user under whose authority Apache is running) doesn't have authority to open a file in your home directory. But we can't tell, because you didn't show us the error message that the open() command produced. Please post a little code, and we can probably help you more effectively. :)

No good deed goes unpunished. -- (attributed to) Oscar Wilde