tobold.org

correct • elegant • free

△ comp.lang.perl △

◅ Need help on sockets

Open for Read & Write? ... and FLOCK ▻

How do I access a DBM as read-only

>Newsgroups: comp.lang.perl.misc,comp.lang.perl.modules,comp.lang.perl

Why did you crosspost this to the modules group?  It's almost never
appropriate to crosspost to foo.bar and foo.misc.

comp.lang.perl doesn't exist any more.

Anyway...

>Subject: How do I access a DBM as read-only

If you're using Perl 5, the tie function gives you much more control
than dbmopen.  This code will tie %hash to the NDBM database in 'file'
in a read only fashion.  Subsequent attempts to alter %hash will result
in a fatal "No write permission" error.

    use Fcntl;
    use NDBM_File;
    tie %hash, NDBM_File, 'file', O_RDONLY, undef or die "tie failed: $!\n";

Tim.
--
Tim Goodwin   | "A language needs both intestines and guts." -- Larry Wall

Original headers:

From: tim@pipex.net (Tim Goodwin)
Newsgroups: comp.lang.perl.misc
Subject: Re: How do I access a DBM as read-only
Date: 15 Jan 1997 14:38:57 GMT
Organization: UUNET PIPEX
Message-ID: <5biq61$a34@join.news.pipex.net>
References: <32DBDE21.29F6@ie.utoronto.ca>

△ comp.lang.perl △

◅ Need help on sockets

Open for Read & Write? ... and FLOCK ▻