Yes, I know someone just posted a "reading a DBM" question, but this is a little different than his problem. Actually, it makes me feel like a stupid n00b because I'm probably missing something really simple.
I am using the following code to read a list of names from a DBM file. All I want to do is see if a name exists in the list. As such, the DBM file Is just a name followed by the number 1 on each line. This is the code I use to check for a specific name:
#!/usr/bin/perl -w use strict; use DB_File; my %names; tie %names, 'DB_File', 'names.db' || die "$!"; print $names{'drew'}
Whenever I do that, I get "Use of uninitialized value in print." However, when I use the following code to iterate through the names, I get the entire list:
while(my ($key, $value) = each(%names)) { print "$key\t".$names{$key}."\n"; }
I know I'm doing something wrong, but I can't quite figure out what it is. Of course if there's an easier way to do this, I'd be glad to hear it too.
In reply to Can't seem to read DBM by dirtdart
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |