in reply to Re^2: Help please, or Urgent help needed!
in thread Help please, or Urgent help needed!

How about reading with block. If you set input separator with empty string, you will get block.
#!/usr/bin/perl use strict; use warnings; open( my $fh, '<', "ldif.file") or die $!; $/=""; while( my $item=<$fh> ){ print "===========\n"; print "$item\n"; print "===========\n"; if ($item =~ /something/is ){ print "as you like\n"; } } close $fh; __DATA__ =========== dn: uid=testing,ou=comp,o=test.com dpwnc: BH mail: example@great.com sn: example =========== =========== dn: uid=testing1,ou=comp,o=test.com dpwnc: CH mail: example1@great.com sn: example1 =========== =========== dn: uid=testing2,ou=comp,o=test.com dpwnc: DH mail: example2@great.com sn: example2 ===========

Replies are listed 'Best First'.
Re^4: Help please, or Urgent help needed!
by anakin30 (Acolyte) on Mar 28, 2012 at 02:51 UTC

    I wish to print output as below, can you please explain more detail how i can get this output?" meanwhile i appreciate if you could tell me what do you mean by print "as you like"?

    I'm still beginner in perl scripting, couldn't get it. I'm sorry. Please explain further.

    dn: uid=testing,ou=comp,o=test.com mail: example@great.com dn: uid=testing1,ou=comp,o=test.com mail: example1@great.com dn: uid=testing2,ou=comp,o=test.com mail: example2@great.com

      Once you get "block" successfully, you can pick your needed item with regex or split.

      You can split with newline character, /\n/. http://perldoc.perl.org/functions/split.html

      perlretut is very important regex introduction for me. I would like you also read it.

      And you will be recommended to search cpan with keyword like LDIF. good luck.

      A reply falls below the community's threshold of quality. You may see it by logging in.