develooper Front page | perl.ldap | Postings from January 2018

RE: Net::LDAP::Entry - RFC

Thread Previous | Thread Next
"Burns, Victor M" via perl-ldap
January 2, 2018 13:50
RE: Net::LDAP::Entry - RFC
Message ID:
Thanks for getting back to me. I suspect I confused the version number. As you know perl-ldap is a large set of classes. I am using the latest perl-ldap-0.65 and the class in Question Net::LDAP::Entry is 0.27 and is confirmed both on my system and on CPAN at this link; which shows it is version 0.27 and is part of perl-ldap-0.65

As I mentioned it might be nice if the ldif method supported additional options. I found it useful to have a wrap => 0 option to disable wrapping. For now I get around the issue by cheating. In a class I've written I fudge a new method, ldif_nowrap, into the Net::LDAP::Entry namespace, "God bless PERL!" that hardcodes the ( wrap => 0 ) into it and I call it in the place of the regular ldif method. I do it this way and avoid the Perl redefined subroutine warning all together. I'm a huge fan of strict and warnings! I don't write anything without them. :)

package Net::LDAP::Entry;

use strict;
use warnings;

sub ldif_nowrap
  my $self = shift;
  my %opt = @_;

  require Net::LDAP::LDIF;
  open(my $fh, '>', \my $buffer);
  my $change = exists $opt{change} ? $opt{change} : $self->changes ? 1 : 0;
  my $ldif = Net::LDAP::LDIF->new($fh, 'w', wrap => 0, change => $change);
  return $buffer;

But it would be just as easy for the original method to be updated to look something like this. I've not tested this but it visually looks okay.

sub ldif
  my $self = shift;
  my %opt = @_;

  require Net::LDAP::LDIF;
  open(my $fh, '>', \my $buffer);
  my $change = exists $opt{change} ? $opt{change} : $self->changes ? 1 : 0;
  my @wrap = exists $opt{wrap} ? ( wrap => $opt{wrap} ) : ();
  my $ldif = Net::LDAP::LDIF->new($fh, 'w', @wrap, change => $change);
  return $buffer;

Best Regards,
Victor Burns

-----Original Message-----
From: Peter Marschall [] 
Sent: Thursday, December 28, 2017 6:26 AM
To:; Burns, Victor M <>
Subject: Re: Net::LDAP::Entry - RFC

Hi Victor,

Am Donnerstag, 27. Juli 2017, 13:42:13 CET schrieb Burns, Victor M via perl-
> I've been working with the Net::LDAP::Entry class.
> I think it would be keen/natural if the ->ldif method supported additional
> Net::LDAP::LDIF options. For example:
> print $entry->ldif( wrap => 0 );
> I inspected the method and it seems that only the change option is
> supported. I have version 0.27

Sorry for anwering this late.

As Chris ridd wrote 0.27 is veeeeery old - from 2003 ,if I remember correctly.
Since then perl-ldap gained lots of features.
Please do yourself a favour and update to a recent version.

While not directly fulfilling your request, the newer versions have an 
extended Net::LDAP::Entry->update() method, that allows using an LDIF file as 
a target to write to.

Best regards

Peter Marschall

This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at   If you are not the intended recipient, please delete this message.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About