From: Paul D. F. <pd...@mo...> - 2003-03-13 09:20:38
|
I've had a small problem with Entry->changes(). It might, perhaps, be my use but I think that N::L::Entry->changes warrants a small change. This seems reasonable idiom: for my $entry ($mesg->entries) { if (some_test1($entry)) { $entry->add("field1" => $value); } if (some_test2($entry)) { $entry->replace("field2" => $value); } . . $entry->update($ldap) if $entry->changes; } But if there are no changes (a condition that arose only after several weeks in use), changes() complained about an undefined value. I've changed changes(): sub changes { my $ref = shift->{'changes'}; $ref ? @$ref : (); } ensuring that an undef ref is not de-ref'd. Reasonable? Paul Fardy <pd...@mu...> *** lib/Net/LDAP/Entry.pm Tue May 28 05:41:04 NDT 2002 --- new/Net/LDAP/Entry.pm Thu Mar 13 05:22:09 NST 2003 *************** *** 287,293 **** } sub changes { ! @{shift->{'changes'}} } 1; --- 287,294 ---- } sub changes { ! my $ref = shift->{'changes'}; ! $ref ? @$ref : (); } 1; |