more useful options | |
PerlMonks |
Re: Re: Re: Re: Re: Re: DB_File, not savingby jsprat (Curate) |
on Jul 18, 2003 at 00:36 UTC ( [id://275461]=note: print w/replies, xml ) | Need Help?? |
I must be able to tie %chat to both objects otherwise it's useless Pretty strong words, partner ;-) I think what you mean is that to pull this off you must be able to represent the data in a sorted manner. First off, sauoq was right on about IxHash. Second, diotalevi says to use $DB_BTREE. An excellent suggestion, as long as you use a sensible key - maybe date/time stamp - and be aware of the possibility of duplicates. It will always be sorted - it's stored in a balanced tree. The key your script uses is $cnt, but I don't see it being initialized anywhere (probably not a sensible key ;). Every message is stuffed into the same slot, overwriting the previous message. The most straightforward short-term solution for you IMO would be to use $DB_RECNO like so:
You'll be able to treat @chat like an ordinary array. As a bonus, you'll be able to view or modify the chat db file with any text editor.
In Section
Seekers of Perl Wisdom
|
|