in reply to Re: building an ldif from 2 files
in thread building an ldif from 2 files

I fixed this by changing the code (see below). However, I need an empty line after the employeeNumber: 123456789 line, how is the "print OUT...constructed? I tried print OUT; print OUT ""; print OUT \n; Ideas? #! perl -slw use strict; use warnings; use constant batchdir => "e:\meta"; open DN, "<DDNs3" or die $!; open UID, "<DDNsUid2" or die $!; open OUT, ">DDNs3.ldif" or die $!; while( <DN> ) { chomp; print OUT "dn: $_"; print OUT "changetype: modify"; print OUT "replace: employeeNumber"; chomp( my $empNo = <UID> ); print OUT "employeeNumber: $empNo"; print OUT; }; close OUT; close UID; close DN;

Replies are listed 'Best First'.
Re^3: building an ldif from 2 files
by BrowserUk (Patriarch) on May 26, 2010 at 16:52 UTC

    Yes. The code is untested. Switch all '\'s in the path names to '/'s and Perl will do the right thing. Also, I just noticed a typo: nfile2 should be infile2.

    There may well be other bugs or typos you'll need to fix. There idea here is for use to help you (learn Perl), not just give you solutions, so you may have to put a little effort in :)


    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.