Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: Help please, or Urgent help needed!

by anakin30 (Acolyte)
on Mar 27, 2012 at 19:55 UTC ( #962008=note: print w/ replies, xml ) Need Help??

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

i have re-updated perl script code, pointing line to for the error..

Comment on Re^2: Help please, or Urgent help needed!
Replies are listed 'Best First'.
Re^3: Help please, or Urgent help needed!
by remiah (Hermit) on Mar 27, 2012 at 20:45 UTC
    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, dpwnc: BH mail: sn: example =========== =========== dn: uid=testing1,ou=comp, dpwnc: CH mail: sn: example1 =========== =========== dn: uid=testing2,ou=comp, dpwnc: DH mail: sn: example2 ===========

      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, mail: dn: uid=testing1,ou=comp, mail: dn: uid=testing2,ou=comp, mail:

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

        You can split with newline character, /\n/.

        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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://962008]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2015-11-29 12:23 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (750 votes), past polls