[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] tieing Hashes



At 07.19 -0500 1999.01.27, Rob Myers wrote:
>use Fcntl;

Not required with DB_File, which exports all the Fnctl "constants" you
would need.  But one of your several main problem is that you don't use the
Fcntl constants provided (see below).

>use DB_File;
>
>tie %db, 'DB_FILE', 'my.db', 0666

First, it is NOT 'DB_FILE'.  Case matters!

Second, you leave out the flags.  From the man page:

 [$X =] tie %hash,  'DB_File', [$filename, $flags, $mode, $DB_HASH] ;

You get the case wrong on DB_File, then you add the filename, leave out the
flags, and add the mode.  Finally, you forget to check for errors.  I'll
quote myself from a post last week:

#!perl -w
use DB_File;
tie(%db, 'DB_File', 'my.db', O_RDWR|O_CREAT, 0644) or die "couldn't tie it:
$!";


You need to use -w.  You need to check $!.  You need to read the docs.  You
need to be precise.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch