So, you've got
%$hash whose values are arrayrefs, and you've got
%$values whose keys are things you're looking for, and you want to find those keys
$k in
%$hash such that
@{$hash->{$k}} contains a key from
%$values. Is that the problem you're trying to solve?
Assuming it is, then it seems grep and array are pretty much what you're after (try as you might to avoid them), since you're asking for $k such that grep { $values->{$_} } @{$hash->{$k}} is nonempty.
OK, this isn't going to work that well for large lists, because grep can't short-circuit and you'll waste time after you "already" know the answer is yes. Maybe wait for Perl 6? No, probably not a good idea. So you'll need to do your own short-circuiting by iterating over @{$hash->{$k}} and quitting when you've found something that matches.
Since nothing is sorted anywhere in this exercise, I don't think you'll do much better than "iterate over the keys of %$hash, then iterate over the entries in the arrayref and check each one".
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.