From: | Torsten "Förtsch" <torsten.foertsch [...] gmx.net> |
To: | perl-ldap-dev [...] lists.sourceforge.net |
Subject: | Patch to Net::LDAP::LDIF |
Date: | Mon, 6 May 2002 17:31:56 +0200 |
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;
}
Show quoted text
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net