Find largest file coverage of smallest number of repeating lines from tail.
authorjkratoch <>
Thu, 17 Sep 2009 01:44:42 +0000 (01:44 +0000)
committerjkratoch <>
Thu, 17 Sep 2009 01:44:42 +0000 (01:44 +0000)
bin/replines [new file with mode: 0755]

diff --git a/bin/replines b/bin/replines
new file mode 100755 (executable)
index 0000000..be4125d
--- /dev/null
@@ -0,0 +1,24 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+
+my @l=<>;
+
+my @replen;
+REPLEN: for my $replen (1..@l) {
+       for my $tried (@replen) {
+               next REPLEN if ($replen%$tried)==0;
+       }
+       my $repcountx;
+       REPCOUNT: for my $repcount (2..@l/$replen) {
+               for my $repline (0..$replen-1) {
+                       next if $l[@l-$replen+$repline] eq $l[@l-$replen*$repcount+$repline];
+                       $repcountx=$repcount-1;
+                       last REPCOUNT;
+               }
+       }
+       next if !$repcountx || $repcountx==1;
+       my $covered=$replen*$repcountx;
+       print "$replen lines ${repcountx}x covers $covered of ".int(@l)." = ".int(100*$covered/@l)."%\n";
+       push @replen,$replen;
+}