Sorry, but your description is still quite unclear and your code does not run because it contains a lot of variables that we don't know about (I'm going to guess they aren't relevant to the question either). If you could please reduce your problem down to: short sample input, runnable code, the expected output for that input, and the actual output you're getting, including any error messages, each within <code> tags. As choroba already said, please read SSCCE, and also How do I post a question effectively?.

Just for fun, I'm going to take a guess at what you might mean. Note this is a brute force approach that I just whipped up, there's probably a much more intelligent algorithm than this.

use warnings; use strict; my @input = qw/ 51:50 51:50:47 51:50:47:42 37:30 51:50:47:42:37:30 /; my %seen; for my $in (@input) { my @items = split /:/, $in; my @subsets; for my $start (0..$#items-1) { for my $end ($start+1..$#items) { push @subsets, join ":", @items[$start..$end]; } } @subsets = sort { length $b <=> length $a } @subsets; my @seen; for my $subset (@subsets) { push @seen, $subset if $seen{$subset}++; } if (@seen) { my $new = $in; my ($re) = map {qr/\b(?:$_)\b/} join '|', map { quotemeta } @seen; 1 while $new =~ s/$re/:/g; $new =~ s/:+/:/g; $new =~ s/\A:|:\z//g; $new = length $new ? "'$new' is new" : "nothing is new"; print "In '$in', I've seen ", join('/', map {"'$_'"} @seen), " before, $new.\n"; } else { print "I have not seen '$in' before, it is new.\n"; } } __END__ I have not seen '51:50' before, it is new. In '51:50:47', I've seen '51:50' before, '47' is new. In '51:50:47:42', I've seen '51:50:47'/'51:50'/'50:47' before, '42' is + new. I have not seen '37:30' before, it is new. In '51:50:47:42:37:30', I've seen '51:50:47:42'/'51:50:47'/'50:47:42'/ +'51:50'/'50:47'/'47:42'/'37:30' before, nothing is new.

In reply to Re^2: Scanning Hashes for Repeated values by haukex
in thread Scanning Hashes for Repeated values by Anonymous Monk

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.