Next The Perl Hardware Store DC.pm Version 25

Semaphore Files

         $FILE = '/data/hitcounter';
         $SEMAPHORE = $FILE . '.lck';
         print "Content-type: text/html\n\n";
         open S, "> $SEMAPHORE" or die ...;
         if (something()) {
           flock S, LOCK_SH or die ...;
           open F, $FILE or die ...;
           print while <F>;
         } else {
           flock S, LOCK_EX or die ...;
           open F, "> $FILE" or die ...;
           my $data = qx{some command};
           print F $data;
         }
         close F;  close S;


Next Copyright © 2003 M. J. Dominus