On Wed, 28 Nov 2001, Ahmed Moustafa Ibrahim Ahmed <[EMAIL PROTECTED]> wrote,

> Hi Nafiseh,
> 
> I think can't open a file for reading and writing at the same time. 
> Anyway, the following should help:
> 
> #------------------------------
> open (FILE, $file) || die "Can't open $file: $!\n";
> $value = <FILE>;
> close (FILE);
> 
> $value += 10;
> 
> open (FILE, ">$file") || die "Can't open $file: $!\n";
> print FILE "$value";
> close FILE;
> #------------------------------
> 
> I don't know if it can be done in less code or not.

Yes, and safer also.

perldoc -q lock
perldoc perlfaq5

    I still don't get locking.  I just want to incre­
    ment the number in the file.  How can I do this?


san
-- 
Trabas - http://www.trabas.com



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

Reply via email to