Good Morning! I searched around and I didn't find much on it. I have 2 array references and I am searching one for combinations of keys that match the other one. The inner one is the small one. When I find one, I would like to remove it from the inner array to reduce the total search space on the next iteration. My example shows the algorithm, but I didn't post the loading of the arefs. Any recommendations on a different algorithm? Any recommendations on how to modify that array? I saw in the Perl Docs that delete will be deprecated.
any suggestions would be good.
thanks
-theleftsock
use warnings;
use strict;
my ($outer_hr_aref, $inner_hr_aref);
foreach my $outer_href (@$outer_hr_aref) {
foreach my $inner_href (@$inner_hr_aref) {
if (($$outer_href{key1} eq $$inner_href{key2}) & ($$outer_href
+{key3} == $$inner_href{key4})) { #abitrary key assignment could be ot
+her combinations
print "status found: $$inner_href matching $outer_href\n";
$$outer_href{key1} = 'something_new'; #arbitrary, other fu
+nction calls can occur
#somehow now remove the $inner_href item from the @$inner_
+hr_aref so i don't have to search the entire aref again.
last;
}
}
}
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.