I encountered an interesting situation in one of our hash uses. We are using BerkeleyDB::Hash to tie our hashes to files so we can access them "randomly" (over the web). However, some of the people that read these will, on occasion, forget to enter their query in the right case. I was looking at using Hash::Case::Preserve to tie the hash to allow for case-insensitive matching.
The best way I can do this so far is to do something like:
tie my %seqindex, "BerkeleyDB::Hash",
-Filename => $globals{seq_xref},
-Flags => DB_RDONLY
or goto bail;
tie my %alt_seqindex, 'Hash::Case::Preserve';
foreach my $key (keys %seqindex){
$alt_seqindex{$key} = $seqindex{$key};
};
which means that the hash %alt_seqindex is the one I end up doing most of my searches on. It seems that building this second hash takes a
very long time. I was wondering if there is a way to make that first
tie statement use both the BerkeleyDB and Hash::Case::Preserve modules so that it ends up with a hash that is searchable in a case-insensitive manner?
Or if there are any other ways to do this quicker?
The hash value
$globals{$seq_xref} refers to the name of the hash file that we're reading in.
Thank you
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.