From: Graham B. <gb...@us...> - 2003-06-02 15:13:20
|
Update of /cvsroot/perl-ldap/ldap/lib/Net/LDAP In directory sc8-pr-cvs1:/tmp/cvs-serv13441/lib/Net/LDAP Modified Files: Constant.pm Log Message: Support :all to export all constants (not recoomended but for backwards complatability) Index: Constant.pm =================================================================== RCS file: /cvsroot/perl-ldap/ldap/lib/Net/LDAP/Constant.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Constant.pm 20 May 2003 14:58:49 -0000 1.8 +++ Constant.pm 2 Jun 2003 15:13:10 -0000 1.9 @@ -4,7 +4,7 @@ package Net::LDAP::Constant; -$VERSION = "0.01"; +$VERSION = "0.02"; use Carp; @@ -15,7 +15,8 @@ my $callpkg = caller(0); _find(@_); my $oops; - foreach my $sym (@_) { + my $all = grep /:all/, @_; + foreach my $sym ($all ? keys %const : @_) { if (my $sub = $const{$sym}) { *{$callpkg . "::$sym"} = $sub; } @@ -30,11 +31,12 @@ sub _find { if (my @need = grep { ! $const{$_} } @_) { my %need; @need{@need} = (); + my $all = exists $need{':all'}; seek(DATA,0,0); local $/=''; # paragraph mode local $_; while(<DATA>) { - next unless /^=item\s+(LDAP_\S+)\s+\((.*)\)/ and exists $need{$1}; + next unless /^=item\s+(LDAP_\S+)\s+\((.*)\)/ and ($all or exists $need{$1}); my ($name, $value) = ($1,$2); delete $need{$name}; $const{$name} = sub () { $value }; |