Update of /cvsroot/perl-ldap/sasl/lib/Authen/SASL
In directory sc8-pr-cvs1:/tmp/cvs-serv17820/lib/Authen/SASL
Modified Files:
Perl.pm
Log Message:
Cache result of require-ing a module the first time to avoid false positives
Index: Perl.pm
===================================================================
RCS file: /cvsroot/perl-ldap/sasl/lib/Authen/SASL/Perl.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Perl.pm 21 Oct 2003 18:59:47 -0000 1.5
+++ Perl.pm 2 Jan 2004 23:24:41 -0000 1.6
@@ -8,13 +8,14 @@
use vars qw($VERSION);
use Carp;
-$VERSION = "1.03";
+$VERSION = "1.04";
my %secflags = (
noplaintext => 1,
noanonymous => 1,
nodictionary => 1,
);
+my %have;
sub client_new {
my ($pkg, $parent, $service, $host, $secflags) = @_;
@@ -30,7 +31,8 @@
my @mpkg = sort {
$b->_order <=> $a->_order
} grep {
- eval "require $_;" && $_->_secflags(@sec) == @sec
+ my $have = $have{$_} ||= (eval "require $_;" and $_->can('_secflags')) ? 1 : -1;
+ $have > 0 and $_->_secflags(@sec) == @sec
} map {
(my $mpkg = __PACKAGE__ . "::$_") =~ s/-/_/g;
$mpkg;
@@ -40,7 +42,7 @@
$mpkg[0]->_init($self);
}
-sub _order { 0 }
+sub _order { 0 }
sub code { defined(shift->{error}) || 0 }
sub error { shift->{error} }
sub service { shift->{service} }
|