I like kennethk's idea. But since you asked about a hash way, I'll show a way...see below. This of course is a memory hog! But 14,000 hash keys wouldn't necessarily be considered "huge". The code to build the hash look up table is simple and then you would just query it for values of $vector. How efficient this thing has to be is of course a matter of your application. Something like this might be more appropriate if the "lane buckets" weren't contiguous or if there were multiple ranges associated with each lane.
#!/usr/bin/perl -w use strict; use Data::Dumper; my @lanes = ( [(200900..202543)], [(202544..204187)], [(204188..205831)], [(205832..207475)], [(207476..210119)], [(210120..211763)], [(211764..213407)], [(213408..215051)], ); my %hash; my $lane =1; foreach my $aref (@lanes) { @hash{@$aref} = ($lane) x @$aref; $lane++; } my $vector = 210121; print $hash{$vector}; #prints 6

In reply to Re: match with elements in array by Marshall
in thread match with elements in array by finder003

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.