Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DB_File - flock

Posted on 1998-11-01
5
Medium Priority
?
192 Views
Last Modified: 2010-03-04
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
0
Comment
Question by:Evernight
  • 4
5 Comments
 

Author Comment

by:Evernight
ID: 1205859
Adjusted points to 150
0
 

Author Comment

by:Evernight
ID: 1205860
I don't think I've ever spent so much time trying to figure out what the leters "dup" stand for. ;p
0
 

Author Comment

by:Evernight
ID: 1205861
Anyone have any idea?  Even a hint or suggestion?  Please.
0
 

Author Comment

by:Evernight
ID: 1205862
Adjusted points to 209
0
 

Accepted Solution

by:
Igloo earned 800 total points
ID: 1205863
Try RDWR intead of RDRW ;-)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question