From: Torsten F. <tor...@gm...> - 2002-05-06 15:30:19
|
Hi I am using Net::LDAP::LDIF version 0.09 to read in the output of OpenLDAP's ldapsearch utility. ldapsearch generates a comment before every entry like this: # DbagItb-bf-geo-st-bauwerk-gleis-bahnsteigabschnitt, oc, config, itb, db-sta tion, db-ag, de dn: oc=DbagItb-bf-geo-st-bauwerk-gleis-bahnsteigabschnitt,conf=oc,soa=config,s ys=itb,ou=db-station,o=db-ag,c=de ... If the comment is continued as shown on the next line Net::LDAP::LDIF returns an error: First line of LDIF entry does not begin with 'dn:'". Simply exchanging 2 lines of the code of sub _read_lines fixed the problem: sub _read_lines { my $self = shift; my @ldif; { local $/ = ""; my $fh = $self->{'fh'}; my $ln = $self->{_next_lines} || scalar <$fh>; unless ($ln) { $self->{_next_lines} = ''; $self->{_current_lines} = ''; $self->eof(1); return; } ######################################################## # I have exchanged the next 2 lines. $ln =~ s/\n //sg; $ln =~ s/^#.*\n//mg; ######################################################## chomp($ln); $self->{_current_lines} = $ln; chomp(@ldif = split(/^/, $ln)); $self->{_next_lines} = scalar <$fh> || ''; $self->eof(1) unless $self->{_next_lines}; } @ldif; } |