in reply to Substr Perl

Might I recommend that you use an actual LDAP tool/module to manipulate what very much appears to be an LDIF file?