in reply to Will these functions for use with Storable properly lock my file?

Storable supports advisory locking out of the box:

# Advisory locking use Storable qw(lock_store lock_nstore lock_retrieve) lock_store \%table, 'file'; lock_nstore \%table, 'file'; $hashref = lock_retrieve('file');

This is from the Storable POD. Could you use these tools to handle locking for you?


Dave

  • Comment on Re: Will these functions for use with Storable properly lock my file?
  • Download Code

Replies are listed 'Best First'.
Re^2: Will these functions for use with Storable properly lock my file?
by nysus (Parson) on Aug 03, 2021 at 21:33 UTC

    I had initially tried using the locking functions provided with Storable. Maybe I wasn't using them properly but the processes stomped all over one another. That's when I did some searching and decided to try out a semaphore file instead.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks