2.15. counter

2.15.1. Summary

Parameters: file

Positional parameters in same order.

Invalidates cache: YES

Called Routine:

ASP-like Perl call:

    $Tag->counter(
        {
         file => VALUE,
        }
    )

 OR

    $Tag->counter($file, $ATTRHASH);

Attribute aliases

            name ==> file

2.15.2. Description

Manipulates a persistent counter, by default incrementing it and returning the new value.

The counter value is stored in the specified file. If the file name begins with a "/" then it is an absolute path. Otherwise, it is relative to VendRoot. The default file is etc/counter. If the file does not exist, it is created and initialized to the value of the start parameter.

The counter is implemented using Perl's File::Counter module, which protects the file against simultaneous access by multiple processes.

WARNING: This tag will not work under Safe, i.e. in embedded Perl.

Additional parameters:

2.15.2.1. decrement=1

Causes the counter to count down instead of up.

2.15.2.2. start=50

Causes a new counter to be created and to start from 50 (for example) if it did not exist before.

2.15.2.3. value=1

Shows the value of the counter without incrementing or decrementing it.