App-File-Grepper
view release on metacpan or search on metacpan
lib/App/File/Grepper.pm view on Meta::CPAN
}
my $exclude;
if ( defined $opts->{exclude} ) {
$exclude = $opts->{exclude};
$exclude = qr/$exclude/;
}
else {
$exclude = qr{ (?: ^\# | ^\.\.?(?!/) | ~$ ) }x;
}
binmode( STDOUT, ":utf8" );
my $grepper = sub {
# Prune VC dirs. Always.
if ( -d $_ && $_ =~ /^(RCS|CVS|\.svn|\.git|\.hg)$/ ) {
$File::Find::prune = 1;
return;
}
# Files only.
lib/App/File/Grepper.pm view on Meta::CPAN
# Okay, we've got one.
open( my $fh, '<', $file )
or warn("$File::Find::name: $!\n"), return;
unless ( -T $fh ) {
warn("[Binary: $File::Find::name]\n") if $opts->{verbose};
return;
}
binmode( $fh, 'raw' );
use Encode qw(decode);
while ( <$fh> ) {
eval {
$_ = decode( 'UTF-8', $_, 1 );
}
or $_ = decode( 'iso-8859-1', $_ );
( run in 0.253 second using v1.01-cache-2.11-cpan-87723dcf8b7 )