How to read and write a file without open file twice? Thanks in advance.

M

mike

I'd like to code a function that performs read and write a file. The
file is for recording serial no, just a number inside. Each time when
the function is called, the file will be opened, locked, read,
increase the serial no, write, unlocked and closed, then return the
serial no in the end.

Is it possible to do the read and write operations in one file-open
with file lock? Thanks in advance
 
B

Ben Morrow

Quoth mike said:
I'd like to code a function that performs read and write a file. The
file is for recording serial no, just a number inside.

perldoc -q increment

Ben
 
R

Ron Bergin

I'd like to code a function that performs read and write a file. The
file is for recording serial no, just a number inside. Each time when
the function is called, the file will be opened, locked, read,
increase the serial no, write, unlocked and closed, then return the
serial no in the end.

Is it possible to do the read and write operations in one file-open
with file lock? Thanks in advance

use File::CounterFile;
http://search.cpan.org/~gaas/File-CounterFile-1.04/CounterFile.pm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top