Lavezzi has asked for the wisdom of the Perl Monks concerning the following question:
I have about 6 files full of traceroute data which I need to analyze for changes (e.g. Differences in number of hops, how often the route changes).
The inside of the files look like this at the moment:
I need to write code in perl that will: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 etc.
1. Read the first section of data (A)
2. Compare it to the next section of data (B)
3. Print outfile if the Route/IPs have changed
4. Store the data again (B)
5. Compare it to the next section of data (C)
6. Repeat until the end of the file.
I tried myself to write the code which would do this, but I failed miserably. I was thinking along the lines of two loops that would alternate with each other after each line break, but to be honest I'm not sure if that would be the best method to compare the data.
If anyone could help me come up with an idea or solution to comparing the data, I would be incredibly grateful.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Best way to compare my data?
by Corion (Patriarch) on Mar 28, 2010 at 15:20 UTC | |
by Lavezzi (Initiate) on Mar 28, 2010 at 15:37 UTC | |
by Corion (Patriarch) on Mar 28, 2010 at 15:52 UTC | |
by planetscape (Chancellor) on Mar 29, 2010 at 04:41 UTC | |
|
Re: Best way to compare my data?
by Perlbotics (Archbishop) on Mar 28, 2010 at 17:35 UTC | |
|
Re: Best way to compare my data?
by GrandFather (Saint) on Mar 28, 2010 at 19:48 UTC | |
by Lavezzi (Initiate) on Mar 29, 2010 at 16:26 UTC | |
by planetscape (Chancellor) on Apr 01, 2010 at 10:43 UTC | |
|
Re: Best way to compare my data?
by GrandFather (Saint) on Mar 29, 2010 at 20:42 UTC | |
by Lavezzi (Initiate) on Apr 01, 2010 at 22:39 UTC |