| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Goo::Grepper; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
|
4
|
|
|
|
|
|
|
# Nigel Hamilton |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
|
7
|
|
|
|
|
|
|
# All Rights Reserved |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
|
10
|
|
|
|
|
|
|
# Filename: Goo::Grepper.pm |
|
11
|
|
|
|
|
|
|
# Description: Grep all the files in a directory for a pattern |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# Date Change |
|
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
15
|
|
|
|
|
|
|
# 15/06/2005 Auto generated file |
|
16
|
|
|
|
|
|
|
# 15/06/2005 Needed to do fast backlink calculations for The Goo! |
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
############################################################################### |
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
5
|
use Goo::Prompter; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
23
|
|
|
23
|
1
|
|
|
1
|
|
4
|
use File::Grep qw(fdo); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
271
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
############################################################################### |
|
27
|
|
|
|
|
|
|
# |
|
28
|
|
|
|
|
|
|
# find_files - find all the files that match a pattern in a directory |
|
29
|
|
|
|
|
|
|
# |
|
30
|
|
|
|
|
|
|
############################################################################### |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub find_files { |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
0
|
1
|
|
my ($pattern, $directory, $suffix) = @_; |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my @files = glob "$directory/*.$suffix"; |
|
37
|
0
|
|
|
|
|
|
my @filenames; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
fdo { |
|
40
|
0
|
|
|
0
|
|
|
my ($file, $pos, $line) = @_; # iterate all given filenames |
|
41
|
0
|
0
|
0
|
|
|
|
if ($line =~ qr/$pattern/ && # if any line in a filename matches $pattern AND |
|
42
|
|
|
|
|
|
|
$files[$file] =~ /([^\/]+)$/ |
|
43
|
|
|
|
|
|
|
) { # we can extract just the filename |
|
44
|
|
|
|
|
|
|
# print "found match $1 \n"; |
|
45
|
0
|
|
|
|
|
|
push @filenames, $1; # push it to list of filenames |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
0
|
|
|
|
|
|
@files; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# print "found these filenames " . join("\n", @filenames); |
|
51
|
0
|
|
|
|
|
|
return @filenames; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Goo::Grepper - Grep all the files in a directory for a pattern |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use Goo::Grepper; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Grep through files trying to find a string. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item find_files |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
find all the files in a directory that match a pattern |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=back |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
87
|
|
|
|
|
|
|
|