Hello,

For the life of me, I can't figure out what you meant to write. I presume that is because you formatted what you wrote nicely in your window, but did not include the tags that make paragraphs and separate code from text. So all of it became one long line.

You can try and re-edit your question using the tags to make your question more readable (See Writeup Formatting Tips). Trying to guess what you may have intended, I believe that perhaps there were two columns, something like:

order_id, time_mins 096000BN, 32 096000BP, 85 096000BG, 132 096000Be, 85 096000BP, 32 & etc.... ...
I would like to perform a match on array value at position 0 i.e.: $array[$i[0]] and if the match found find a difference between values in corresponding position 1.

I guess that you mean: where there are matches in column 1, you want to see the time difference. Yes hashes would be the way to go here. In each hash position, keep an array of times. For example if we had this data in a file, we could read the file and do:

my %hash; while (<>) { my ($id,$time) = split /,/; push @{$hash{$id}}, $time; } for (keys %hash) { print "@{$hash{$id}}\n"; }
This will get you started. You can then do the differences as you like. If you want to know the position of the matches, you need to do some extra.

In reply to Re: Comparing elements of array... by b4swine
in thread Comparing elements of array... by angelfish

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.