You'd endear yourself more if you followed the (simple) local formatting conventions.

Lots of room for error checking, but ought to work. (Note: This writes the file directly. No redirection required.)

#! perl -slw use strict; use constant batchdir => "e:\meta"; use constant { infile => batchdir . "\DDNs3"; nfile2 => batchdir . "\DDNsUid2"; outfile => "DDNs3.ldif", ## Assume outfile n current dir per .cmd }; unlink outfile; ## If there delete it; silently do nothing if not. open DN, '<', infile or die $!; open UID, '<', infile2 or die $!; open OUT, '>', outfile or die $!; while( <DN> ) { chomp; print OUT "dn: $_"; print OUT "changetype: notify"; print OUT "replace: employeeNumber"; chomp( my $empNo = <UID> ); print OUT "employeeNumber: $empNo"; } close OUT; close UID, close DN; __END__ @echo on ::Set BATCH Input Directory set batchdir=e:\meta ::Set the input file containing the list set infile=%batchdir%\DDNs3 set infile2=%batchdir%\DDNsUid2 ::If exists, we remove output file rm DDNs3.ldif ::For loop below process each line in the input list. :uid FOR /F "tokens=* delims=" %%i IN (%infile%) do ( echo dn: %%i echo changetype: modify echo replace: employeeNumber call :loop2 ) goto :eof :loop2 FOR /F "tokens=* delims=" %%k IN (%infile2%) do ( echo employeeNumber: %%k echo. call :uid ) :eof

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

In reply to Re: building an ldif from 2 files by BrowserUk
in thread building an ldif from 2 files by rfransix

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.