http://qs321.pair.com?node_id=24715


in reply to Opening files

You have to include the path to the file, either relative to where you are, or an absolute path, unless the file is in the same current directory as you are. Your current directory is wherever you were when you ran the script, if you're running from the command line. If you're running from a webserver, your current directory is the directory where the script is. You can affect the directory with the chdir function.

For example, if you are in the directory /home/you and you want to open file.txt in the directory /home/me, you could open the file in 3 different ways:

open(FILE, "/home/me/file.txt") or die "$!"; #absolute path open(FILE, "../me/file.txt") or die "$!"; #relative path chdir("../me") or die "$!"; open(FILE, "file.txt") or die "$!"; #current dir