DB_File - flock

This is an attempt to flock a database, a modified version of a snippet of code from the PERL docs at http://www.perl.com/CPAN-local/doc/manual/html/lib/DB_File.html#HINTS_AND_TIPS.

# begin code

use DB_File;
use Fcntl;
# ...
$database = "/home/test/temp.dbm";
$db = tie(%hash, DB_File, $database, O_RDRW|O_CREAT, 0777) || die "Could not tie database!";
$fd = $db->fd;
open(DB_FH, "+<&=$fd") || die "dup ($!)";  # dies here
flock (DB_FH, 1);
# ...
flock (DB_FH, 8);
undef $db;
untie(%hash);
close(DB_FH);

# end code

The error arises from the line: open(DB_FH, "+<&=$fd").  Now, I understand  the concept behind "+<&$fd", but why would this open fail when the tie() did not?  The script terminates without setting $!.

If anyone can answer this I would really appreciate it.  Pardon any typos, its been a long weekend.

Daniel Crowe
Evernight Design
EvernightAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
IglooConnect With a Mentor Commented:
Try RDWR intead of RDRW ;-)
0
 
EvernightAuthor Commented:
Adjusted points to 150
0
 
EvernightAuthor Commented:
I don't think I've ever spent so much time trying to figure out what the leters "dup" stand for. ;p
0
 
EvernightAuthor Commented:
Anyone have any idea?  Even a hint or suggestion?  Please.
0
 
EvernightAuthor Commented:
Adjusted points to 209
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.