5
pfunc - grep for perl functions
9
pfunc subroutine FILES...
13
B<pfunc> searches the named FILES for all calls to the given
14
subroutine. It will report back the file and line number each call is
15
found on along with what sort of call it is
18
class method Class->foo()
19
object method $obj->foo()
23
$ pfunc isa /usr/share/perl/5.6.1/*.pm
24
Called as function in /usr/share/perl/5.6.1/CGI.pm at line 316
25
Called as function in /usr/share/perl/5.6.1/CGI.pm at line 327
26
Called as function in /usr/share/perl/5.6.1/CGI.pm at line 397
27
Called as function in /usr/share/perl/5.6.1/CGI.pm at line 494
28
Called as function in /usr/share/perl/5.6.1/CGI.pm at line 495
29
Called as object method in /usr/share/perl/5.6.1/CPAN.pm at line 4957
30
Called as function in /usr/share/perl/5.6.1/Dumpvalue.pm at line 191
31
Called as function in /usr/share/perl/5.6.1/Dumpvalue.pm at line 218
32
Called as function in /usr/share/perl/5.6.1/Dumpvalue.pm at line 248
33
Called as function in /usr/share/perl/5.6.1/Dumpvalue.pm at line 251
34
Called as function in /usr/share/perl/5.6.1/Dumpvalue.pm at line 254
35
Called as object method in /usr/share/perl/5.6.1/Shell.pm at line 28
36
Called as object method in /usr/share/perl/5.6.1/base.pm at line 12
40
Its not fast, but its accurate.
44
Michael G Schwern <schwern@pobox.com>
58
foreach my $file (@ARGV) {
59
my $mod = Module::Info->new_from_file($file);
61
warn "Can't find $file\n";
64
my @calls = sort { $a->{line} <=> $b->{line} }
65
grep { defined $_->{name} and $_->{name} eq $func }
66
$mod->subroutines_called;
67
foreach my $call (@calls) {
68
my $as = $call->{type} =~ /class method/
69
? "$call->{type} via $call->{class}"
71
printf "Called as %s in %s at line %d\n",
72
$as, $file, $call->{line}