On 02/21/2007 03:49 PM, RICHARD FERNANDEZ wrote:
Probably rfernandez is not a valid key in the database file. Try this:

     tie my %db, 'NDBM_File', 'aliases', O_RDWR, 0644;

     while (my ($key, $value) = each %db) {
         print "$key => $value\n";
     }

     untie %db;

On my system, this code works with a custom aliases database file I created in Perl (aliases.dir and aliases.pag). However, I used simple numbers for the values, but a true aliases file probably uses binary-packed values.


HTH

Thanks Mumia. I had already tried this w/o success.

I removed the O_CREAT switch (per your sample) and started to see "No
such file or directory" when clearly the file was sitting right there. I
also tried providing the path (./aliases). Same error.

Then it occurred to me that maybe I should try the test code on the
"production" box which runs Solaris and perl 5.8.2. My dev box is OBSD
and runs perl 5.8.6.

The test code runs perfectly on the Solaris box! I have no idea what's
going on under the covers. Maybe someone can shed some light on this?

Anyway at least now I know I'm not barking up the wrong tree :)

Oh, and BTW it turns out that the aliases file does not use
binary-packed values as you suggest. It looks to be straight alias =>
address(es) pairs as I expected before the subject came up.

Thanks to all!

richf


Load NDBM_File and check what else is loaded. This is what I get:

$ perl -mNDBM_File -le 'print for values %INC'
/usr/share/perl/5.8/warnings/register.pm
/usr/lib/perl/5.8/XSLoader.pm
/usr/share/perl/5.8/Carp.pm
/usr/lib/perl/5.8/NDBM_File.pm
/usr/share/perl/5.8/Exporter.pm
/usr/share/perl/5.8/strict.pm
/usr/share/perl/5.8/Tie/Hash.pm
/usr/share/perl/5.8/warnings.pm

I'm using Perl 5.8.4 and NDBM_File 1.05 on Debian 3.1.

Check the docs for your version of NDBM_File. The maintainers of your O/S may have made NDBM_File an alias for another DBM module.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to