Skip to content

Instantly share code, notes, and snippets.

@drewblas
Created July 15, 2010 14:59
Show Gist options
  • Save drewblas/477060 to your computer and use it in GitHub Desktop.
Save drewblas/477060 to your computer and use it in GitHub Desktop.
# Copyright 2010 Drew Blas <[email protected]>
# 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