use strict;
use lib 'jumi';
use WebLib;
use File::Find;
use File::Basename;
my ( $folder, $tofind, $tofile, $exclude, $cs ) = @ARGV;
my @tofind = split '&&',$tofind;
#strip whitespace
@tofind = grep(s/\s*$//g, @tofind);
@tofind = grep(s/^\s*//g, @tofind);
foreach(@tofind) {print "|$_|
";}
print "
Excluded:
$exclude
";
find(\&wanted, $folder);
print qq {};
sub wanted {
my $file = $File::Find::name;
return unless -T $file;
return unless $file =~ /$tofile/;
return if $file =~ /$exclude/ && $exclude;
if ($tofind) {
open F, $file or print "couldn't open $file\n" && return;
my $file_contents = do { local $/; };
close F;
my $print = 'Y';
foreach (@tofind) {
if ($cs == 1){
if ($file_contents !~ /$_/m) {$print = 'N'};
} else {
if ($file_contents !~ /$_/mi) {$print = 'N'};
}
}
if ($print eq 'Y'){
print qq {|
$file |
};
} #end if
} else {
print qq {|
$file |
};
}