1ODBM_File(3pm) Perl Programmers Reference Guide ODBM_File(3pm)
2
3
4
6 ODBM_File - Tied access to odbm files
7
9 use Fcntl; # For O_RDWR, O_CREAT, etc.
10 use ODBM_File;
11
12 # Now read and change the hash
13 $h{newkey} = newvalue;
14 print $h{oldkey};
15 ...
16
17 untie %h;
18
20 "ODBM_File" establishes a connection between a Perl hash variable and a
21 file in ODBM_File format;. You can manipulate the data in the file
22 just as if it were in a Perl hash, but when your program exits, the
23 data will remain in the file, to be used the next time your program
24 runs.
25
26 Use "ODBM_File" with the Perl built-in "tie" function to establish the
27 connection between the variable and the file. The arguments to "tie"
28 should be:
29
30 1. The hash variable you want to tie.
31
32 2. The string "ODBM_File". (Ths tells Perl to use the "ODBM_File"
33 package to perform the functions of the hash.)
34
35 3. The name of the file you want to tie to the hash.
36
37 4. Flags. Use one of:
38
39 "O_RDONLY"
40 Read-only access to the data in the file.
41
42 "O_WRONLY"
43 Write-only access to the data in the file.
44
45 "O_RDWR"
46 Both read and write access.
47
48 If you want to create the file if it does not exist, add "O_CREAT"
49 to any of these, as in the example. If you omit "O_CREAT" and the
50 file does not already exist, the "tie" call will fail.
51
52 5. The default permissions to use if a new file is created. The
53 actual permissions will be modified by the user's umask, so you
54 should probably use 0666 here. (See "umask" in perlfunc.)
55
57 On failure, the "tie" call returns an undefined value and probably sets
58 $! to contain the reason the file could not be tied.
59
60 "odbm store returned -1, errno 22, key "..." at ..."
61 This warning is emitted when you try to store a key or a value that is
62 too long. It means that the change was not recorded in the database.
63 See BUGS AND WARNINGS below.
64
66 There are a number of limits on the size of the data that you can store
67 in the ODBM file. The most important is that the length of a key, plus
68 the length of its associated value, may not exceed 1008 bytes.
69
70 See "tie" in perlfunc, perldbmfilter, Fcntl
71
72
73
74perl v5.16.3 2013-03-04 ODBM_File(3pm)