On Thursday 23 December 2004 11:27 pm, Adam Butler wrote: > For some reason, when I try to use the open() function to create a new > file, it doesn't work. It will open a pre-existing file just fine, but if > you enter a file that doesn't exist, instead of creating a new one it > simply does nothing.
First thing you should do is get perl to tell you why it can't open the file: open(FH, "/path/to/file") || die "$!\n"; Most likely it's a permission problem - die "$!\n" will report something like: "Permission denied" - You do not have permission to open the file. "No such file or directory" - File does not exist or path to file is wrong. Are you trying to append to a file or write over it or just read it? To append to a file open it like this: open(FH, ">> /path/to/file") || die "$!\n"; To overwrite the file: open(FH, "> /path/to/file") || die "$!\n"; To simply read from the file: open(FH, "/path/to/file") || die "$!\n"; Cheers! -- cs