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; 
http://search.cpan.org/~marschap/perl-ldap-0.65/lib/Net/LDAP/Entry.pod 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);
  $ldif->write_entry($self);
  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);
  $ldif->write_entry($self);
  return $buffer;
}


Best Regards,
Victor Burns


-----Original Message-----
From: Peter Marschall [mailto:pe...@adpm.de] 
Sent: Thursday, December 28, 2017 6:26 AM
To: perl-ldap@perl.org; Burns, Victor M <victor.bu...@bankofamerica.com>
Subject: Re: Net::LDAP::Entry - RFC

Hi Victor,

Am Donnerstag, 27. Juli 2017, 13:42:13 CET schrieb Burns, Victor M via perl-
ldap:
> 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








-- 
Peter Marschall
pe...@adpm.de

----------------------------------------------------------------------
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 
http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended 
recipient, please delete this message.

Reply via email to