Hello,

On Sun, May 26, 2002 at 05:42:24PM +0300, Octavian Rasnita wrote:
> 
> I have seen more advices to check if a file can be opened, but if I put
> something like:
> 
> open (FILE, "$file") or die "Can't open the file $file - $!";
> 
> ..... after I run the script, if it can't find that file on the disk, the
> script dies and it shows me that message in the log file.
> Shouldn't it create that file instead of dieing?

No, the default open mode is for reading. If you want to create or
append to the file, you may better use:

open (FILE, ">> $file") or die "Can't open the file $file - $!";

On first run, that should create the file, latter runs should append
to the file, if you are creating a counter, maybe you want to
overwrite the file, in which case you may use:

open (FILE, "> $file") or die "Can't open the file $file - $!";

There should be other modes more appropiate to create a file for a
counter (like for updating it), for that you may want to check:

perldoc perlopentut

God bless you.
Roberto Ruiz

--
A train stops at a train station; a bus stops at a bus station; on my
desk I have a workstation...

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to