SYN SYN
[p5sagit/p5-mst-13.2.git] / ext / ODBM_File / ODBM_File.pm
CommitLineData
a0d0e21e 1package ODBM_File;
2
96318ac8 3use strict;
96318ac8 4
5require Tie::Hash;
cb50131a 6use XSLoader ();
a0d0e21e 7
cb50131a 8our @ISA = qw(Tie::Hash);
9our $VERSION = "1.02";
c07a80fd 10
146174a9 11XSLoader::load 'ODBM_File', $VERSION;
a0d0e21e 12
131;
14
15__END__
a5f75d66 16
17=head1 NAME
18
19ODBM_File - Tied access to odbm files
20
21=head1 SYNOPSIS
22
22d4bb9c 23 use Fcntl; # For O_RDWR, O_CREAT, etc.
a5f75d66 24 use ODBM_File;
25
22d4bb9c 26 # Now read and change the hash
27 $h{newkey} = newvalue;
28 print $h{oldkey};
29 ...
30
31 untie %h;
32
33=head1 DESCRIPTION
34
35C<ODBM_File> establishes a connection between a Perl hash variable and
36a file in ODBM_File format;. You can manipulate the data in the file
37just as if it were in a Perl hash, but when your program exits, the
38data will remain in the file, to be used the next time your program
39runs.
a5f75d66 40
22d4bb9c 41Use C<ODBM_File> with the Perl built-in C<tie> function to establish
42the connection between the variable and the file. The arguments to
43C<tie> should be:
a5f75d66 44
22d4bb9c 45=over 4
46
47=item 1.
48
49The hash variable you want to tie.
50
51=item 2.
52
53The string C<"ODBM_File">. (Ths tells Perl to use the C<ODBM_File>
54package to perform the functions of the hash.)
55
56=item 3.
57
58The name of the file you want to tie to the hash.
59
60=item 4.
61
62Flags. Use one of:
63
64=over 2
65
66=item C<O_RDONLY>
67
68Read-only access to the data in the file.
69
70=item C<O_WRONLY>
71
72Write-only access to the data in the file.
73
74=item C<O_RDWR>
75
76Both read and write access.
77
78=back
79
80If you want to create the file if it does not exist, add C<O_CREAT> to
81any of these, as in the example. If you omit C<O_CREAT> and the file
82does not already exist, the C<tie> call will fail.
83
84=item 5.
85
86The default permissions to use if a new file is created. The actual
87permissions will be modified by the user's umask, so you should
88probably use 0666 here. (See L<perlfunc/umask>.)
89
90=back
91
92=head1 DIAGNOSTICS
93
94On failure, the C<tie> call returns an undefined value and probably
95sets C<$!> to contain the reason the file could not be tied.
96
97=head2 C<odbm store returned -1, errno 22, key "..." at ...>
98
99This warning is emmitted when you try to store a key or a value that
100is too long. It means that the change was not recorded in the
101database. See BUGS AND WARNINGS below.
102
103=head1 BUGS AND WARNINGS
104
105There are a number of limits on the size of the data that you can
106store in the ODBM file. The most important is that the length of a
107key, plus the length of its associated value, may not exceed 1008
108bytes.
a5f75d66 109
22d4bb9c 110See L<perlfunc/tie>, L<perldbmfilter>, L<Fcntl>
a5f75d66 111
112=cut