On 13/6/02 12:13 am, Andrew Tristan <atr...@ac...> wrote:
> I'm writing some code to take a dump of our LDAP server, perform some
> modifications, and then write out the result as input to slapadd (I'm
> actually outputting it to a file at the moment).
>
> So, I read in an ldif entry, perform some modifications, and then write
> it out to a new ldif file. The problem is that while,
> $ldifEntry->delete([qw(attr1,attr2,attr3)]);
> does absolutely nothing (not what I expected),
> $ldifEntry->delete('attr1');
> $ldifEntry->delete('attr2');
> $ldifEntry->delete('attr3');
> results in those attributes being removed from the new ldif entries.
> Am I doing something wrong?
Yup, The qw operator (man perlop) splits the contents into separate values
at whitespace, not commas (ie a single attribute called
"attr1,attr2,attr3"). You are then passing the results of qw inside an array
and passing a reference to that array (via the [ ]) as the argument to
delete. The delete method just takes an array of attributes, not a reference
to an array.
This might work better:
$ldifEntry->delete(qw(attr1 attr2 attr3));
As might this:
$ldifEntry->delete('attr1', 'attr2', 'attr3');
Cheers,
Chris
|