Hello Monks, I have two files to compare. One file contains employee data from a database and the other file contains LDAP directory information in LDIF format.

My question is: How would I open both files, read in all of the contents into arrays, key in on the username as a match-point and update the LDIF file with data from the employee database?

This is what the employee data contains:

dn: uid=simpsonh givenName: Homer sn: Simpson department: Nuclear Control Center buildingName: Radioactive Hall telephoneNumber: 218 555-6793 faxNumber: 218 555-6798 title: Nuclear Control Operator manager: uid=burnsm
Here is data from the LDIF file:

dn: uid=simpsonh,ou=People,dc=sfnp,dc=com userPassword:: e1NTSEF9dkI0NnhHT1A5MTBdgfsdghfSFWHDFW239jhsdv= cn: Homer Simpson givenName: Homer sn: Simpson mail: simpsonh@sfnp.com loginShell: /bin/ksh objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: posixAccount objectClass: operator uidNumber: 111 gidNumber: 101 uid: simpsonh timeOut: 1128100385 auditDate: Mon Nov 7 04:50:00 2005 memberOf: cn=Operators,ou=Groups,dc=sfnp,dc=com ssn: 1111 firstTime: 0 homeDirectory: /export/home/simpsonh

...and this is what it should look like when all said and done:

dn: uid=simpsonh,ou=People,dc=sfnp,dc=com userPassword:: e1NTSEF9dkI0NnhHT1A5MTBdgfsdghfSFWHDFW239jhsdv= cn: Homer Simpson givenName: Homer sn: Simpson mail: simpsonh@sfnp.com loginShell: /bin/ksh objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: posixAccount objectClass: operator uidNumber: 111 gidNumber: 101 uid: simpsonh timeOut: 1128100385 auditDate: Mon Nov 7 04:50:00 2005 memberOf: cn=Operators,ou=Groups,dc=sfnp,dc=com ssn: 1111 firstTime: 0 homeDirectory: /export/home/simpsonh department: Nuclear Control Center buildingName: Radioactive Hall telephoneNumber: 218 555-6793 faxNumber: 218 555-6798 title: Nuclear Control Operator manager: uid=burnsm

Thank you in advance for any help and guidance.


In reply to Compare Two Files, Merge Updates from One File to the Other by rycher

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.