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

Discussion in 'Perl Misc' started by mike, Sep 25, 2007.

  1. mike

    mike Guest

    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
     
    mike, Sep 25, 2007
    #1
    1. Advertising

  2. mike

    Ben Morrow Guest

    Quoth 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.


    perldoc -q increment

    Ben
     
    Ben Morrow, Sep 25, 2007
    #2
    1. Advertising

  3. mike

    Ron Bergin Guest

    On Sep 25, 11:31 am, mike <> wrote:
    > 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
     
    Ron Bergin, Sep 26, 2007
    #3
  4. mike

    mike Guest

    cool!
    Guys thanks a lot.
     
    mike, Sep 26, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ÀÏÓà
    Replies:
    0
    Views:
    365
    ÀÏÓà
    May 4, 2005
  2. david
    Replies:
    3
    Views:
    117
    kaeli
    Aug 14, 2003
  3. Derek Richards

    Help Please! Thanks in advance.

    Derek Richards, Oct 21, 2003, in forum: Javascript
    Replies:
    2
    Views:
    89
    Derek Richards
    Oct 22, 2003
  4. PerlPerl
    Replies:
    12
    Views:
    172
    A. Sinan Unur
    May 30, 2005
  5. Replies:
    2
    Views:
    103
    Tad J McClellan
    Oct 18, 2008
Loading...

Share This Page