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

Hi Folks,

I have a text file which is shown below.

hi how are you? how are you? how are you? Good to see you at perlmonks.org bye see you!

Here I want my text file to pose the question- how are you?, only one time. (as shown below)

hi how are you? Good to see you at perlmonks.org bye see you!

Waiting for your suggestions.

Thanks.

Replies are listed 'Best First'.
Re: Deleting a string which is repeating(more than once) in a file.
by Corion (Patriarch) on May 21, 2012 at 09:22 UTC

    This is a FAQ. Please see perlfaq4 for "duplicate", or type perldoc -q duplicate at your command prompt.

Re: Deleting a string which is repeating(more than once) in a file.
by johngg (Canon) on May 21, 2012 at 09:54 UTC
    Waiting for your suggestions.

    I would suggest that you have a go at writing some code to solve your problem, see whether it works, make an effort to debug any errors or failures in logic and then, if you are still stuck, post the code here so that we can help you.

    Simply providing you with the code to do this will not help you to learn and develop your skills!

    Cheers,

    JohnGG

Re: Deleting a string which is repeating(more than once) in a file.
by aaron_baugher (Curate) on May 21, 2012 at 12:53 UTC
    uniq <input >output

    Aaron B.
    Available for small or large Perl jobs; see my home node.

Re: Deleting a string which is repeating(more than once) in a file.
by ansh batra (Friar) on May 21, 2012 at 12:46 UTC

    Iterate over the lines of file
    compare the current line with $temp
    if current line is Not same as $temp then print it to the output file.
    update the $temp to current line


    I hope now you can apply some perl code