X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2FNDBM_File%2FNDBM_File.pm;h=b88e657dbfb0d7b3b240cebf23fcf4b3c1f76f9a;hb=280cf07eab629d0d4801176eedac7fefa4afecc7;hp=99aae17d5c67e0804b4ff773eda8bd8518c97b96;hpb=0e06870bf080a38cda51c06c6612359afc2334e1;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/NDBM_File/NDBM_File.pm b/ext/NDBM_File/NDBM_File.pm index 99aae17..b88e657 100644 --- a/ext/NDBM_File/NDBM_File.pm +++ b/ext/NDBM_File/NDBM_File.pm @@ -1,16 +1,13 @@ package NDBM_File; -BEGIN { - if ($] >= 5.002) { - use strict; - } -} +use strict; +use warnings; require Tie::Hash; use XSLoader (); our @ISA = qw(Tie::Hash); -our $VERSION = "1.04"; +our $VERSION = "1.07"; XSLoader::load 'NDBM_File', $VERSION; @@ -27,15 +24,18 @@ NDBM_File - Tied access to ndbm files use Fcntl; # For O_RDWR, O_CREAT, etc. use NDBM_File; + tie(%h, 'NDBM_File', 'filename', O_RDWR|O_CREAT, 0666) + or die "Couldn't tie NDBM file 'filename': $!; aborting"; + # Now read and change the hash $h{newkey} = newvalue; - print $h{oldkey}; + print $h{oldkey}; ... - + untie %h; - + =head1 DESCRIPTION - + C establishes a connection between a Perl hash variable and a file in NDBM_File format;. You can manipulate the data in the file just as if it were in a Perl hash, but when your program exits, the @@ -52,14 +52,14 @@ C should be: The hash variable you want to tie. -=item 2. +=item 2. The string C<"NDBM_File">. (Ths tells Perl to use the C package to perform the functions of the hash.) -=item 3. +=item 3. -The name of the file you want to tie to the hash. +The name of the file you want to tie to the hash. =item 4. @@ -100,7 +100,7 @@ sets C<$!> to contain the reason the file could not be tied. =head2 C -This warning is emmitted when you try to store a key or a value that +This warning is emitted when you try to store a key or a value that is too long. It means that the change was not recorded in the database. See BUGS AND WARNINGS below.