# Advisory locking use Storable qw(lock_store lock_nstore lock_retrieve) lock_store \%table, 'file'; lock_nstore \%table, 'file'; $hashref = lock_retrieve('file'); [...] The "lock_store" and "lock_nstore" routine are equivalent to "store" and "nstore", except that they get an exclusive lock on the file before writing. Likewise, "lock_retrieve" does the same as "retrieve", but also gets a shared lock on the file before reading.