On Thursday, September 25, 2003, at 12:33 AM, Greenhalgh David wrote:

On Wednesday, Sep 24, 2003, at 20:05 Etc/GMT, Ken Williams wrote:


Nope. When you open for reading ("<"), it won't be auto-created. It will when you open for writing or appending (">" or ">>").

-Ken

Not necessarily on every Mac. The same thing happens to me here, opening a file for writing does not create the file.


Well then, you didn't succeed in opening it for writing. =)

Try the following code, it will either die or create the files, depending on your permissions:

---------------------------
#!/usr/bin/perl
open FH, "> foo_write" or die "Can't create foo_write: $!";
print FH "some data\n";
close FH;

open FH, ">> foo_append" or die "Can't create foo_append: $!";
print FH "some data\n";
close FH;
---------------------------

There should be no variation of this behavior on any platform perl runs on, '>' and '>>' will always create the file first.

-Ken



Reply via email to