jeanluca has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

When I run the following script
#!/usr/bin/perl # what_did_i_say doom@kzsu.stanford.edu # 07 May 2004 use warnings; use strict; $|=1; my %fried; use Fcntl; # For O_RDWR, O_CREAT, etc. use NDBM_File; my $read_write_create = O_RDWR; $read_write_create += O_CREAT; tie(%fried, 'NDBM_File', 'fried-hash.dbm', $read_write_create, 0666) or die "$0: tie failed: $!"; print "Last time you said: $fried{egg} \n" if defined( $fried{egg} ); $fried{egg} = $ARGV[0]; print "But I'll remember you said: $fried{egg}\n"; untie(%fried);
it produces on a specific system the following error:
./tie.pl: tie failed: No locks available at ./tie.pl line 15.
I guess this is an OS issue, but is there a perl-fix for this problem (turn locking off somehow!)?

cheers

Replies are listed 'Best First'.
Re: tie NDBM_File --> No locks available at ....
by cdarke (Prior) on Jan 25, 2010 at 17:33 UTC
    Works for me.

    I seem to remember that there is an exclusive lock on the NDBM file (fried-hash.dbm), you might wish to check that there is not another process using it. Failing that, perhaps you had a crash which left the file locked. Try removing the file before running the script.
      on all systems I've tested this script it works for me too, except for 1 system. I've removed the files, but thats not it!
Re: tie NDBM_File --> No locks available at ....
by gmargo (Hermit) on Jan 25, 2010 at 19:32 UTC

    You speculate that it may be an OS issue, but you fail to specify just what OS you're using. (Your program works on my Ubuntu 8.04 Linux box.)

    If it's a Linux or Unix OS then perhaps your account is limited in the number of file locks it is allowed (settable in /etc/security/limit.conf). If you're using SE-linux, that may apply additional restrictions. You can see current locks in /proc/locks.

      thnx for your reply.
      Its a Debian system. I found out that I tried my script on a NFS partition, which was the problem!

      cheers