• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

t/H23-Jan-2004-12375

ChangesH A D23-Jan-20041.6 KiB7033

CounterFile.pmH A D03-May-20225.9 KiB262150

MANIFESTH A D08-Jan-200470 87

Makefile.PLH A D30-Jul-2002196 97

READMEH A D06-Oct-20032.3 KiB5742

README

1NAME
2    File::CounterFile - Persistent counter class
3
4SYNOPSIS
5     use File::CounterFile;
6     $c = File::CounterFile->new("COUNTER", "aa00");
7
8     $id = $c->inc;
9     open(F, ">F$id");
10
11DESCRIPTION
12    This module implements a persistent counter class. Each counter is
13    represented by a separate file in the file system. File locking is
14    applied, so multiple processes might try to access the same counters at
15    the same time without risk of counter destruction.
16
17    You give the file name as the first parameter to the object constructor
18    ("new"). The file is created if it does not exist.
19
20    If the file name does not start with "/" or ".", then it is interpreted
21    as a file relative to $File::CounterFile::DEFAULT_DIR. The default value
22    for this variable is initialized from the environment variable "TMPDIR",
23    or /usr/tmp is no environment variable is defined. You may want to
24    assign a different value to this variable before creating counters.
25
26    If you pass a second parameter to the constructor, that sets the initial
27    value for a new counter. This parameter only takes effect when the file
28    is created (i.e. it does not exist before the call).
29
30    When you call the "inc()" method, you increment the counter value by
31    one. When you call "dec()" the counter value is decrementd. In both
32    cases the new value is returned. The "dec()" method only works for
33    numerical counters (digits only).
34
35    You can peek at the value of the counter (without incrementing it) by
36    using the "value()" method.
37
38    The counter can be locked and unlocked with the "lock()" and "unlock()"
39    methods. Incrementing and value retrieval is faster when the counter is
40    locked, because we do not have to update the counter file all the time.
41    You can query whether the counter is locked with the "locked()" method.
42
43    There is also an operator overloading interface to the File::CounterFile
44    object. This means that you might use the "++" operator for incrementing
45    the counter, "--" operator for decrementing and you can interpolate
46    counters diretly into strings.
47
48COPYRIGHT
49    Copyright (c) 1995-1998,2002,2003 Gisle Aas. All rights reserved.
50
51    This library is free software; you can redistribute it and/or modify it
52    under the same terms as Perl itself.
53
54AUTHOR
55    Gisle Aas <gisle@aas.no>
56
57