public
Created — forked from drewblas/compare-thesiswp.pl

  • Download Gist
compare-thesiswp.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
# Copyright 2010 Drew Blas <drew.blas@gmail.com>
# From: http://drewblas.com/2010/07/15/an-analysis-of-gpled-code-in-thesis
#
# 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/>.
 
 
use File::Find::Rule;
@files = File::Find::Rule->file()->name( '*.php' )->in( 'wordpress/' );
 
foreach $file (@files) {
open(fh, $file) || die "unable to open the file <$file>";
#print "open $file\n";
$line = 1;
while( chomp($str = <fh>) )
{
$str =~ s/\s+//g;
$str = lc($str);
$fileHash{$str} = "<$file>:$line" if $str && length($str) > 20;
$line += 1;
}
close(fh);
}
 
$lines = keys( %fileHash );
print "Loaded $lines lines\n\n";
 
@files = File::Find::Rule->file()->name( '*.php' )->in( 'thesis_17/' );
 
foreach $file (@files) {
open(fh, $file) || die "Unable to open the file <$file>";
#print "check $file\n";
$line = 1;
while ( chomp($str = <fh>) ) {
$c_str = $str;
$c_str =~ s/\s+//g;
$c_str = lc($c_str);
$str =~ s/^\s+//;
print "//-- Match from $fileHash{$c_str} to <$file>:$line --\n$str\n\n" if exists $fileHash{$c_str} ;
$line += 1;
}
close(fh);
}
exit 0;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.