Dean Theophilou wrote:
> 
> Hello All:
> 
>         I was wondering if there is any way to create an environment variable under
> UNIX which can be used as a persistent counter.  Can this be done, or you
> limited to whatever environment variables already exist within a system?
> Also, is there an easy way to query environment variables under UNIX like
> there is with Win32 (through the AdminMisc module)?  Thanks.

Something like mod_perl or a shared memory module should do the trick.
Otherwise just use a file and flock.  Not sure if your UNIX supports it or not.

>From Perl perlfunc pod/man page:

    shmctl ID,CMD,ARG
            Calls the System V IPC function shmctl. You'll probably have to
            say

                use IPC::SysV;

            first to get the correct constant definitions. If CMD is
            `IPC_STAT', then ARG must be a variable which will hold the
            returned `shmid_ds' structure. Returns like ioctl: the undefined
            value for error, "`0' but true" for zero, or the actual return
            value otherwise. See also `IPC::SysV' documentation.

    shmget KEY,SIZE,FLAGS
            Calls the System V IPC function shmget. Returns the shared
            memory segment id, or the undefined value if there is an error.
            See also `IPC::SysV' documentation.

    shmread ID,VAR,POS,SIZE
    shmwrite ID,STRING,POS,SIZE
            Reads or writes the System V shared memory segment ID starting
            at position POS for size SIZE by attaching to it, copying
            in/out, and detaching from it. When reading, VAR must be a
            variable that will hold the data read. When writing, if STRING
            is too long, only SIZE bytes are used; if STRING is too short,
            nulls are written to fill out SIZE bytes. Return TRUE if
            successful, or FALSE if there is an error. See also `IPC::SysV'
            documentation and the `IPC::Shareable' module from CPAN.


-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED] 
  / ) /--<  o // //      http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users

Reply via email to