Hi Monks,

I am trying to make an ldif file to update the entries in the directory using this perl script below. This script is not able to get if the xml code goes in to the second line. For example, i am trying to get the complete value for this attribute:

my_attr1:<order>1</order> <code>PxED1</code>
Since code tag goes into second line.My script can't read and search into next line & print.

#!/usr/bin/perl while (defined($file = readdir BIN)) { if (($file=~m/test.txt/)){ open FILE,$file; my @lines=<FILE>; for $line (@lines){ if ($line=~/cn=/) { print "\n"; print "$line"; print "changetype: modify"."\n"; print "delete: my_attr1"."\n"; } elsif (($line=~/^my_attr1/)&& ($line=~/<order>1<\/ +order>/)){ print "$line"; } } } } close(FILE); closedir(BIN);
The text is below :
cn=abc,ou=People,dc=example,dc=com my_attr1:<order>0</order><code>PxED1</code> my_attr1:<order>1</order> <code>PxED1</code> my_attr1:<order>2</order><code>PxED1</code> my_attr1:<order>3/order><code>PxED1</code> uid:abc cn:abc mail:abc1@hotmail.com my_attr2:<site>M1</site> <timestamp>20060301162200.623Z</timestamp> sn:def givenname:abc cn=def,ou=People,dc=example,dc=com my_attr1:<order>1</order> <code>PMxED1</code> uid:def cn:def mail:def@msn.com my_attr2:<site>M1</site> <timestamp>20060301162200.623Z</timestamp> sn:jkl givenname:jkl cn=jkl,ou=People,dc=example,dc=com my_attr1:<order>2</order><code>P1xED1</code> my_attr1:<order>1</order> <code>P1xED1</code> uid:jkl cn:jkl mail:jkl2@hotmail.com my_attr2:<site>M1</site> <timestamp>20060301162200.623Z</timestamp> sn:jkl givenname:jkl cn=mnp,ou=People,dc=example,dc=com my_attr1:<order>1</order><code>PM23xED1</code> uid:mnp cn:mnp mail:mnp@msn.com my_attr2:<site>M123</site> <timestamp>20060301162200.623Z</timestamp> sn:mnp givenname:mnp
Results of script:
$ ./mymakeldif.txt cn=abc,ou=People,dc=example,dc=com changetype: modify delete: my_attr1 my_attr1:<order>1</order> cn=def,ou=People,dc=example,dc=com changetype: modify delete: my_attr1 my_attr1:<order>1</order> cn=jkl,ou=People,dc=example,dc=com changetype: modify delete: my_attr1 my_attr1:<order>1</order> cn=mnp,ou=People,dc=example,dc=com changetype: modify delete: my_attr1 my_attr1:<order>1</order><code>PM23xED1</code>
Thanks for help Zac

In reply to make ldif by zac_carl

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.