Skip to content

Instantly share code, notes, and snippets.

@mattrude
Forked from drewblas/compare-thesiswp.pl
Created November 17, 2011 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattrude/1373777 to your computer and use it in GitHub Desktop.
Save mattrude/1373777 to your computer and use it in GitHub Desktop.
# 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment