Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I have a text file contain 5 paragraphs.
Using perl program, i would like to read 2nd and 4th paragraph.
How can i read that?
Can you please provide some code to solve this problem?
Thanks
Sur

Replies are listed 'Best First'.
Re: Read each paragraph from a text file
by Roy Johnson (Monsignor) on Jun 09, 2004 at 16:57 UTC
    perldoc -q paragraph should get you started.

    The PerlMonk tr/// Advocate
Re: Read each paragraph from a text file
by amw1 (Friar) on Jun 09, 2004 at 16:58 UTC
    This smells of homework so no code.
    basic idea for a fairly ineffecient solution.

    open the file
    loop through each line in the file appending each line to an element in an array
    if you hit the paragraph delimiter incrament the array index
    print the appropriate array indexes.

Re: Read each paragraph from a text file
by pzbagel (Chaplain) on Jun 09, 2004 at 17:35 UTC

    Definately smells of homework here.

    Check out the Input Record Seperator. If you modify that just right, you can get a very efficient paragraph reading loop.

    No code for you!

    Later

Re: Read each paragraph from a text file
by davido (Cardinal) on Jun 10, 2004 at 03:00 UTC