| 1 |
package Perlfiles; |
| 2 |
|
| 3 |
use File::Find; |
| 4 |
|
| 5 |
@wanted = (); |
| 6 |
|
| 7 |
sub perlscript |
| 8 |
{ |
| 9 |
my ($file) = @_; |
| 10 |
open(SCRIPT,"<$file") || die "Cannot open $file:$!"; |
| 11 |
my $line = <SCRIPT>; |
| 12 |
close(SCRIPT); |
| 13 |
return (defined $line && $line =~ /#!.*perl/); |
| 14 |
} |
| 15 |
|
| 16 |
sub wanted |
| 17 |
{ |
| 18 |
$File::Find::prune = 0; |
| 19 |
if (-T $_ && !/%$/) |
| 20 |
{ |
| 21 |
push(@wanted,$File::Find::name) if (/\.p[ml]$/ || perlscript($_)); |
| 22 |
} |
| 23 |
elsif (-d $_) |
| 24 |
{ |
| 25 |
$File::Find::prune = 1 if ($_ eq 'blib'); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
sub main::perlfiles |
| 30 |
{ |
| 31 |
print STDERR "Finding perl scripts and modules\n"; |
| 32 |
@wanted = (); |
| 33 |
@_ = '.' unless (@_); |
| 34 |
find(\&wanted,@_); |
| 35 |
return @wanted; |
| 36 |
} |
| 37 |
|
| 38 |
1; |
| 39 |
|