=head1 NAME Net::LDAP::LDIF - LDIF reading and writing =head1 SYNOPSIS use Net::LDAP::LDIF; $ldif = Net::LDAP::LDIF->new( "file.ldif", "r", onerror => 'undef' ); while( not $ldif->eof() ) { $entry = $ldif->read_entry(); if ( $ldif->error() ) { print "Error msg: ",$ldif->error(),"\n"; print "Error lines:\n",$ldif->error_lines(),"\n"; } else { # do stuff } } $ldif->done(); =head1 DESCRIPTION B provides a means to convert between L objects and LDAP entries represented in LDIF format files. Reading and writing are supported and may manipulate single entries or lists of entries. As when reading an entire file into memory with perl normally, take into account the possibility of memory use when loading an LDIF file in one go. =head1 CONSTRUCTOR =over 4 =item new ( [ FILE [, MODE [,OPTIONS ]]] ) FILE may be the name of a file or an already open filehandle. If a filename is passed in then it will be opened with the mode specified. MODE defaults to "r" for read. You may specify "w" to for write+truncate or "a" for write+append. OPTIONS is a list of key-value pairs. Valid options are: =over 4 =item encode Some values in LDIF cannot be written verbatim and have to be encoded in some way. This option lets you specify how. Valid encoding options are 'none' (the default), 'canonical' (see L), or 'base64'. =back =item onerror If set then Net::LDAP::LDIF will check all responses for errors on all methods. If an error is detected then the specified action will be taken. Valid values and their actions are. =over 4 =item die Net::LDAP::LDIF will croak with an appropriate message. =item warn Net::LDAP::LDIF will warn with an appropriate message. =item undef Net::LDAP::LDIF will warn with an appropriate message if C<-w> is in effect. The method that was called will return C =back =back =head1 METHODS =over 4 =item read_entry Read one entry from the file and return it as a Net::LDAP::Entry object. =item eof Returns true when the end of the file is reached. =item write_entry ( ENTRIES ) =item done This method signals that the LDIF object is no longer needed. If a file was opened automatically when the object was created it will be closed. This method is called automatically via DESTROY when the object goes out of scope. =item error Returns error message if error was found. =item error_lines Returns lines that resulted in error. =item current_entry Returns the current Net::LDAP::Entry object. =item current_lines Returns the lines that generated the current Net::LDAP::Entry object. =item next_lines Returns the lines that will generate the next Net::LDAP::Entry object. =back =head1 AUTHOR Graham Barr . Please report any bugs, or post any suggestions, to the perl-ldap mailing list . =head1 COPYRIGHT Copyright (c) 1997-2000 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =for html
=cut