{
    "mode": "perldoc",
    "parameter": "Net::LDAP::LDIF",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Net%3A%3ALDAP%3A%3ALDIF/json",
    "generated": "2026-06-13T12:28:06Z",
    "synopsis": "use Net::LDAP::LDIF;\n$ldif = Net::LDAP::LDIF->new( \"file.ldif\", \"r\", onerror => 'undef' );\nwhile ( not $ldif->eof ( ) ) {\n$entry = $ldif->readentry ( );\nif ( $ldif->error ( ) ) {\nprint \"Error msg: \", $ldif->error ( ), \"\\n\";\nprint \"Error lines:\\n\", $ldif->errorlines ( ), \"\\n\";\n} else {\n# do stuff\n}\n}\n$ldif->done ( );",
    "sections": {
        "NAME": {
            "content": "Net::LDAP::LDIF - LDIF reading and writing\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Net::LDAP::LDIF;\n\n$ldif = Net::LDAP::LDIF->new( \"file.ldif\", \"r\", onerror => 'undef' );\nwhile ( not $ldif->eof ( ) ) {\n$entry = $ldif->readentry ( );\nif ( $ldif->error ( ) ) {\nprint \"Error msg: \", $ldif->error ( ), \"\\n\";\nprint \"Error lines:\\n\", $ldif->errorlines ( ), \"\\n\";\n} else {\n# do stuff\n}\n}\n$ldif->done ( );\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Net::LDAP::LDIF provides a means to convert between Net::LDAP::Entry objects and LDAP entries\nrepresented in LDIF format files. Reading and writing are supported and may manipulate single\nentries or lists of entries.\n\nAs when reading an entire file into memory with perl normally, take into account the possibility\nof memory use when loading an LDIF file in one go.\n",
            "subsections": []
        },
        "SPECIAL FEATURES": {
            "content": "By default, Net::LDAP::LDIF supports reading attribute values from URLs of type \"file://\".\n\nWhen Gisle Aas' LWP module package is installed, Net::LDAP::LDIF uses it to also support reading\ndata from the URL types supported by these modules; most prominently \"http://\", \"https://\", and\n\"ftp://\" resources. This extended feature is dynamically detected at runtime.\n",
            "subsections": []
        },
        "CONSTRUCTOR": {
            "content": "new ( FILE [[, MODE ], OPTIONS ] )\nOpen the file with the given mode.\n\n\"FILE\" may be the name of a file or an already open filehandle. If \"FILE\" begins or ends\nwith a \"|\" then \"FILE\" will be passed directly to \"open\".\n\n\"MODE\" can be any of the modes allowed for Perl's open() function, potentially extended by\nPerlIO layers as described in perlopentut. Alternatively, it can be one of the mode\nindicators \"r\", \"r+\", \"w\", \"w+\", \"a\", \"a+\" known from C's fopen() function, which get mapped\nto their Perl counterparts. If \"MODE\" is omitted, it defaults to \"r\" for reading.\n\n\"OPTIONS\" is a list of name/value pairs, recognizing:\n\nencode => 'none' | 'canonical' | 'base64'\nSome DN values in LDIF cannot be written verbatim and have to be encoded in some way:\n\n'none'\nThe default.\n\n'canonical'\nSee \"canonicaldn\" in Net::LDAP::Util.\n\n'base64'\nUse base64.\n\nonerror => 'die' | 'warn' | 'undef'\nSpecify what happens when an error is detected.\n\n'die'\n\"Net::LDAP::LDIF\" will croak with an appropriate message.\n\n'warn'\n\"Net::LDAP::LDIF\" will warn with an appropriate message.\n\n'undef'\n\"Net::LDAP::LDIF\" will warn with an appropriate message if \"-w\" is in effect. The\nmethod that was called will return \"undef\".\n\nNote this value is the string 'undef', not the \"undef\" value.\n\nchange => 1\nWrite entry changes to the LDIF file instead of the entries itself. I.e. write LDAP\noperations acting on the entries to the file instead of the entries contents.\n\nlowercase => 1\nConvert attribute names to lowercase when writing.\n\nsort => 1\nSort attribute names when writing entries according to the rule: objectclass first then\nall other attributes alphabetically sorted\n\nversion => '1'\nSet the LDIF version to write to the resulting LDIF file.\n\nAccording to RFC 2849 currently the only legal value for this option is *1*.\n\nWhen this option is set Net::LDAP::LDIF tries to adhere more strictly to the LDIF\nspecification in RFC2489 in a few places.\n\nThe default is *undef* meaning no version information is written to the LDIF file.\n\nwrap => 78\nNumber of columns where output line wrapping shall occur.\n\nDefault is 78. Setting it to 40 or lower inhibits wrapping.\n\nraw => REGEX\nUse REGEX to denote the names of attributes that are to be considered binary when\nreading.\n\nWhen this option is given, Net::LDAP converts all values of attributes not matching this\nREGEX into Perl UTF-8 strings so that the regular Perl operators (pattern matching, ...)\ncan operate as one expects even on strings with international characters.\n\nIf this option is not given, attribute values are treated as byte strings.\n\nExample: raw => qr/(?i:^jpegPhoto|;binary)/\n",
            "subsections": []
        },
        "METHODS": {
            "content": "readentry ( )\nRead one entry from the file and return it as a \"Net::LDAP::Entry\" object.\n\nIn scalar mode, the \"Net::LDAP::Entry\" object is returned alone, while in list mode a list\nis returned consisting of the \"Net::LDAP::Entry\" object as first element followed by all\n\"Net::LDAP::Control\" objects that were part of the LDIF entry. See RFC 2849 for details.\n\neof ( )\nReturns *true* when the end of the file is reached.\n\nwriteentry ( ENTRY [, OPTIONS ], ... )\nWrite entries to the LDIF file.\n\nThe arguments accepted are a list of entries, optionally interspersed with options belonging\nto the preceding entry.\n\nFor each entry, \"OPTIONS\" is a list of key-value pairs, recognizing:\n\ncontrol => CONTROL\ncontrol => [ CONTROL, ... ]\nSee \"CONTROLS\" in Net::LDAP.\n\nwriteversion ( )\nIf the object's version is defined, this method allows one to explicitly write the version\nbefore an entry is written.\n\nIf not called explicitly, it gets called automatically when writing the first entry.\n\nversion ( [ VERSION ] )\nIf called without arguments it returns the version of the LDIF file or undef if no version\nhas been set. If called with an argument it sets the LDIF version to VERSION.\n\nAccording to RFC 2849 currently the only legal value for VERSION is *1*.\n\nhandle ( )\nReturns the file handle the \"Net::LDAP::LDIF\" object reads from or writes to.\n\ndone ( )\nThis method signals that the LDIF object is no longer needed. If a file was opened\nautomatically when the object was created it will be closed. This method is called\nautomatically via DESTROY when the object goes out of scope.\n\nerror ( )\nReturns error message if error was found.\n\nerrorlines ( )\nReturns lines that resulted in error.\n\ncurrententry ( )\nReturns the current \"Net::LDAP::Entry\" object.\n\ncurrentlines ( )\nReturns the lines that generated the current \"Net::LDAP::Entry\" object.\n\nnextlines ( )\nReturns the lines that will generate the next \"Net::LDAP::Entry\" object.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Graham Barr <gbarr@pobox.com>.\n\nPlease report any bugs, or post any suggestions, to the perl-ldap mailing list\n<perl-ldap@perl.org>.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 1997-2004 Graham Barr. All rights reserved. This program is free software; you can\nredistribute it and/or modify it under the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "Net::LDAP::LDIF - LDIF reading and writing",
    "flags": [],
    "examples": [],
    "see_also": []
}