sub containspod {
my($self, $file, $readit) = @_;
return 1 if !$readit && $file =~ /\.pod\z/i;
local($_);
open(TEST,"<", $file) or die "Can't open $file: $!";
while (<TEST>) {
if (/^=head/) {
close(TEST) or die "Can't close $file: $!";
return 1;
}
}
close(TEST) or die "Can't close $file: $!";
return 0;
}It occurs to me that this code may get called on binaries now and then. Would it be behoovey to add a "return 1 if -B $file;" early on? Are there any portability problems with the -B (is binary) switch? It just gives me the willies of the above code line-while'ing over the guts of binaries.
(BTW, I'm the person who refactored perldoc into Pod::Perldoc, but that doesn't make me a big expert on how it works. If I've presumed something wrong about its workings, let me know!)
--
Sean M. Burke http://search.cpan.org/~sburke/
