-
-
Save pije76/928afb27204c6cde39dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
# | |
# Copyright (c) 2010 Ruel Pagayon <[email protected]> - http://ruel.me | |
use strict; | |
use warnings; | |
sub loadf($) { | |
my @file = ( ); | |
open(FILE, $_[0] . "\n") or die("Couldn't Open " . $_[0] . "\n"); | |
@file = <FILE>; | |
close(FILE); | |
return @file; | |
} | |
{ | |
my @file = loadf("path-to-file.txt"); | |
my @inner = @file; | |
my @dup = ( ); | |
my $l0 = 0; my $l1 = 0; my $l2 = 0; my $dc = 0; my $tc; | |
foreach my $line (@file) { | |
$l1++; | |
$line =~ s/^\s+//; | |
$line =~ s/\s+$//; | |
foreach my $iline (@inner) { | |
$l2++; | |
$iline =~ s/^\s+//; | |
$iline =~ s/\s+$//; | |
next if ($l1 == $l2 || grep { $_ eq $l1} @dup ); | |
if ($iline eq $line) { | |
$dc++; | |
if ($dc > 0) { | |
if ($l0 == 0) { | |
print "Line " . $l1 . ": " . $line . "\n"; | |
$l0++; | |
} | |
print "Line " . $l2 . ": " . $iline . "\n"; | |
push (@dup, $l2); | |
} | |
} | |
} | |
print "\n" unless($dc == 0); | |
$dc = 0; $l0 = 0; $l2 = 0; | |
} | |
} | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment