At 07:02 -0400 5/2/1999, Chris Nandor wrote: >It depends on what your data looks like. For data where you have key/value >pairs separated by a |, you can do: > > %hash = map {split /\|/, $_, 2} <FILE>; > >If you have a line without a pipe, though, this will give you problems, >because only one element from that line will go into the hash, and the next >key will become the previous key's value instead of becoming a new key. It >all depends on your data. That's what I was looking for and I used a \t to delimit keys, so it should work. >Well, you can't have a space between O_ and RDWR, and you should not put >".dbm" on the filename. Some DBM libraries will put an extension on for >you, some won't. Just leave it off and you'll be better off. Also, the >tie statement is wrong. You need: > > tie VARIABLE, CLASSNAME, LIST > >So: > > tie(%thehash, 'AnyDBM_File', $filename, $flags, $permissions) or die $!; I typed instead of pasted and there isn't actually a space between O_ and RDWR in the script, but you have a good eye in catching that in the post. Are you saying that the statement should reference variables for flags and permissions? I was going by some stuff in the Camel book in doing it as I did. > >Let us know if that doesn't work. Also, are you using -w and use strict? >Further, are you checking for errors, as my example did? I wasn't using strict but had -w on. If you mean using "or die" for error checking, I am using || die "Couldn't tie hash: $!;" >Bart gave good suggestions for question 3, and I don't think I have >anything else to add to it. As I indicated in reply to him, changing the keys to lower case may not be an option in this particular case. The only reason that I was interested in using a tied hash was because the file is pretty big and I figured that something that was disk based might be a little more efficient if it meant that the whole file was not read into memory every time that the script ran. However, it may be just as fast and more flexible to simply open the file and look for a match from a line start. I guess my question is why bother with a hash, tied or otherwise? Thanks for your help. Richard Gordon -------------------- Gordon Consulting & Design Database Design/Scripting Languages mailto://maccgi@bellsouth.net 770.565.8267 ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org