Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!jarthur!nntp-server.caltech.edu!coil!adler From: adler@coil.caltech.edu (Bo Adler) Newsgroups: comp.lang.perl Subject: Getting keys of a dbm array Message-ID: Date: 25 Jul 90 22:57:16 GMT Sender: news@laguna.ccsf.caltech.edu Distribution: comp Organization: California Institute of Technology Lines: 46 Has anybody else noticed that getting the keys of a dbm array also returns one value which is a concatenation of all the keys and their values? Is there some particular reason for this action? The program I used to discover this follows below... (apologies for the coding style. I'm still learning...:-) -B. Thomas Adler adler@csvax.caltech.edu ------------------------------------- #!/home/adler/bin/perl $file = '/home/adler/src/indexer/test/indx'; print "Index what file? "; chop($indxfl = ); dbmopen(Index, "$file", 0666); open(FOO, "$indxfl"); while (!eof(FOO)) { chop($line = ); $line =~ tr/,.<>=_+|!@#$%^&*()/ /; $line =~ tr/\/\\\-/ /; $line =~ tr/~`;':"{}\[\]/ /; $line =~ tr/A-Z/a-z/; @words = split(/ */, $line); while (defined($word = pop(@words))) { if (!defined($Index{"$word"})) { $Index{"$word"} = 0; } $Index{"$word"} += 1; } } close(FOO); @words = keys %Index; @words = sort(@words); while (defined($word = pop(@words))) { print "$word\n"; } dbmclose(Index); exit;