It's hard to see why you would want to avoid a hash or database since this seems to be exactly what you need.

That being said, here is a version using arrays of arrays. It's quite inefficient as it cycles through the @arr array for every line of @arr2, but it doesn't use a hash or database.

#!/usr/bin/perl use strict; use warnings; my @arr = ( [ "1", "Smith", "Ric" ], [ "1", "Smith", "Rich" ], [ "1", "abc", "A" ], [ "1", "cdeQ", "C Sr" ], [ "1", "ghi", "G" ], [ "2", "cdeQ", "C Sr" ], [ "3", "ghi", "G" ], [ "3", "abc", "A" ], [ "3", "Smith", "Ric" ], [ "4", "cde", "C" ], [ "5", "cde", "C" ], [ "5", "xyz123", "X" ], [ "5", "cdeQ", "C II" ], [ "5", "Smith", "Rich" ] ); # callno lname fi (repeat 3 data points for each FF at each callno) my @arr2 = ( [ "1", "S", "01/05", "04" ], [ "2", "EMS", "01/05", "07" ], [ "3", "VF", "01/05", "11" ], [ "4", "S", "01/05", "13" ], [ "5", "B", "01/05", "17" ] ); # callno type date hr (repeat 4 data points for each incident) my $seen; for my $arr2 (@arr2) { if ( $arr2->[3] ) { # ie, if there's a complete call record print "@$arr2\n"; $seen = $arr2->[0]; print "\tDEBUG: My \$seen: $seen\n\n"; } for my $arr (@arr) { if ( ( $arr->[0] ) && ( $seen == $arr->[0] ) ) { print "@$arr\n"; } } print "\n\t\tFF Array exhausted for Callno $seen\n"; next; } print "\n\t\t No more calls\n";

In reply to Re: Iterating two co-dependant arrays by thundergnat
in thread Iterating two co-dependant arrays by ww

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.