Hi Graham,
I've attached a couple of small files that should demonstrate the problem.
If the data file, ldif_test_dump.ldif has UNIX-style line endings, I get
the correct output:
Person1,+1 098 7654321
Person2,+1 123 4567890
If I change the line endings to Windows-style, then I get only:
,+1 098 7654321
perl is "v5.8.6 built for cygwin-thread-multi-64int", running under
Cygwin on Windows XP.
Cheers,
David
Graham Barr wrote:
On Wed, June 15, 2005 2:47 am, Chris Ridd said:
3) If Net::LDAP::LDIF is run on UNIX but opens a Windows-created LDIF
file (\r\n instead of just \n line endings), read_entry doesn't properly
read in the separate entries.
Can you expand on that. What do you get?
That sounds like a bug.
Yes. Probably the same issue that has been affecting Constant.pm
Graham.
use strict;
use warnings;
use Net::LDAP::Entry;
use Net::LDAP::LDIF;
my $LDIF_INPUT_FILE = "./ldif_test_dump.ldif";
my $ldif = Net::LDAP::LDIF->new($LDIF_INPUT_FILE, "r");
my $entry = undef;
my $cn = "";
my $phone_number = "";
while (!($ldif->eof())) {
$entry = $ldif->read_entry();
if ($ldif->error()) {
print("Error msg: " . $ldif->error() . "\n");
print("Error lines:\n" . $ldif->error_lines() . "\n");
}
else {
$cn = $entry->get_value("cn") if ($entry->exists("cn"));
if ($entry->exists("homePhone")) {
$phone_number = $entry->get_value("homePhone");
print($cn . "," . $phone_number . "\n");
}
}
}
$ldif->done();
dn: cn=Person1,mail=whatever
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
objectclass: mozillaAbPersonObsolete
givenName: Person1
cn: Person1
mail: whatever
modifytimestamp: 0Z
homePhone: +1 098 7654321
dn: cn=Person2,mail=whatever
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
objectclass: mozillaAbPersonObsolete
givenName: Person2
sn: Person2
cn: Person2
mail: whatever
modifytimestamp: 0Z
homePhone: +1 123 4567890