The following uses Algorithm::Diff to do the heavy lifting:

use strict; use warnings; use Algorithm::Diff; my @routes; local $/ = "\n\n"; push @routes, $_ while $_ = <DATA>; chomp @routes; @routes = map {[split "\n"]} @routes; my @reference = @{shift @routes}; my $lenChanges = 0; my $hopChanges = 0; for my $route (@routes) { my @diffs = Algorithm::Diff::diff(\@reference, \@$route); next if !@diffs; @reference != @$route ? ++$lenChanges : ++$hopChanges; } print "Length changes: $lenChanges\n"; print "Hop changes: $hopChanges\n"; __DATA__ 13,4.69.137.70 14,4.69.134.70 15,4.69.134.113 16,4.69.135.185 17,4.69.134.246 18,4.68.18.75 19,4.59.0.10 20,124.211.34.129 21,203.181.100.61 22,118.155.197.140 23,124.211.10.66 24,163.139.130.138 25,163.139.124.57 26,202.215.179.1 27,202.215.179.11 13,4.69.137.74 14,4.69.134.70 15,4.69.134.113 16,4.69.135.185 17,4.69.134.246 18,4.68.18.11 19,4.59.0.10 20,124.211.34.121 21,203.181.100.61 22,118.155.197.140 23,124.211.10.66 24,163.139.130.138 25,163.139.124.57 26,202.215.179.1 27,202.215.179.11 13,4.69.137.70 14,4.69.134.78 15,4.69.134.125 16,4.69.135.185 17,4.69.134.250 18,4.68.18.139 19,4.59.0.10 20,124.211.34.121 21,203.181.100.189 22,118.155.197.140 23,124.211.10.66 24,163.139.130.138 25,163.139.124.57 26,202.215.179.1 27,202.215.179.11 13,4.69.137.74 14,4.69.134.70 15,4.69.134.113 16,4.69.135.185 17,4.69.134.246 18,4.68.18.11 19,4.59.0.10 20,124.211.10.120 20,124.211.26.120 21,203.181.100.61 22,118.155.197.140 23,124.211.10.66 24,163.139.130.138 25,163.139.124.57 26,202.215.179.1 27,202.215.179.11

Prints:

Length changes: 1 Hop changes: 2

Note too the use of the $/ record separator special variable to ease the parsing of the file into records.


True laziness is hard work

In reply to Re: Best way to compare my data? by GrandFather
in thread Best way to compare my data? by Lavezzi

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.