Debian Codegraph @

upstream/debian-unstable/man3/ODBM_File.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "ODBM_File 3perl"
58 .TH ODBM_File 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 ODBM_File \- Tied access to odbm files
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 2
68 \& use Fcntl; # For O_RDWR, O_CREAT, etc.
69 \& use ODBM_File;
70 \&
71 \& # Now read and change the hash
72 \& $h{newkey} = newvalue;
73 \& print $h{oldkey};
74 \& ...
75 \&
76 \& untie %h;
77 .Ve
78 .SH DESCRIPTION
79 .IX Header "DESCRIPTION"
80 \&\f(CW\*(C`ODBM_File\*(C'\fR establishes a connection between a Perl hash variable and
81 a file in ODBM_File format;. You can manipulate the data in the file
82 just as if it were in a Perl hash, but when your program exits, the
83 data will remain in the file, to be used the next time your program
84 runs.
85 .PP
86 Use \f(CW\*(C`ODBM_File\*(C'\fR with the Perl built-in \f(CW\*(C`tie\*(C'\fR function to establish
87 the connection between the variable and the file. The arguments to
88 \&\f(CW\*(C`tie\*(C'\fR should be:
89 .IP 1. 4
90 The hash variable you want to tie.
91 .IP 2. 4
92 The string \f(CW"ODBM_File"\fR. (Ths tells Perl to use the \f(CW\*(C`ODBM_File\*(C'\fR
93 package to perform the functions of the hash.)
94 .IP 3. 4
95 The name of the file you want to tie to the hash.
96 .IP 4. 4
97 Flags. Use one of:
98 .RS 4
99 .ie n .IP """O_RDONLY""" 2
100 .el .IP \f(CWO_RDONLY\fR 2
101 .IX Item "O_RDONLY"
102 Read-only access to the data in the file.
103 .ie n .IP """O_WRONLY""" 2
104 .el .IP \f(CWO_WRONLY\fR 2
105 .IX Item "O_WRONLY"
106 Write-only access to the data in the file.
107 .ie n .IP """O_RDWR""" 2
108 .el .IP \f(CWO_RDWR\fR 2
109 .IX Item "O_RDWR"
110 Both read and write access.
111 .RE
112 .RS 4
113 .Sp
114 If you want to create the file if it does not exist, add \f(CW\*(C`O_CREAT\*(C'\fR to
115 any of these, as in the example. If you omit \f(CW\*(C`O_CREAT\*(C'\fR and the file
116 does not already exist, the \f(CW\*(C`tie\*(C'\fR call will fail.
117 .RE
118 .IP 5. 4
119 The default permissions to use if a new file is created. The actual
120 permissions will be modified by the user's umask, so you should
121 probably use 0666 here. (See "umask" in perlfunc.)
122 .SH DIAGNOSTICS
123 .IX Header "DIAGNOSTICS"
124 On failure, the \f(CW\*(C`tie\*(C'\fR call returns an undefined value and probably
125 sets \f(CW$!\fR to contain the reason the file could not be tied.
126 .ie n .SS """odbm store returned \-1, errno 22, key ""..."" at ..."""
127 .el .SS "\f(CWodbm store returned \-1, errno 22, key ""..."" at ...\fP"
128 .IX Subsection "odbm store returned -1, errno 22, key ""..."" at ..."
129 This warning is emitted when you try to store a key or a value that
130 is too long. It means that the change was not recorded in the
131 database. See BUGS AND WARNINGS below.
132 .SH "SECURITY AND PORTABILITY"
133 .IX Header "SECURITY AND PORTABILITY"
134 \&\fBDo not accept ODBM files from untrusted sources.\fR
135 .PP
136 On modern Linux systems these are typically GDBM files, which are not
137 portable across platforms.
138 .PP
139 The GDBM documentation doesn't imply that files from untrusted sources
140 can be safely used with \f(CW\*(C`libgdbm\*(C'\fR.
141 .PP
142 Systems that don't use GDBM compatibilty for old dbm support will be
143 using a platform specific library, possibly inherited from BSD
144 systems, where it may or may not be safe to use an untrusted file.
145 .PP
146 A maliciously crafted file might cause perl to crash or even expose a
147 security vulnerability.
148 .SH "BUGS AND WARNINGS"
149 .IX Header "BUGS AND WARNINGS"
150 There are a number of limits on the size of the data that you can
151 store in the ODBM file. The most important is that the length of a
152 key, plus the length of its associated value, may not exceed 1008
153 bytes.
154 .PP
155 See "tie" in perlfunc, perldbmfilter, Fcntl