in reply to Re: Can't remember the term to search for help on! (paragraph mode)
in thread Can't remember the term to search for help on!

Thank you to all you kind Perl Monks!! All of the above are great solutions. The INPUT_RECORD_SEPARATOR was what was trying to recall, but you've all offered good solutions. I've only had a chance to try the last solution, and it works like a charm. I didn't realize I could do search and replaces direct from the command line like that. That's awesome! Thanks again!
  • Comment on Re^2: Can't remember the term to search for help on! (paragraph mode)

Replies are listed 'Best First'.
Re^3: Can't remember the term to search for help on! (paragraph mode)
by tom2112 (Novice) on Dec 08, 2009 at 19:33 UTC

    For anyone else that needs to cleanup poorly formatted ebooks in text files, here's what I came up with from the help I received above:


    perl -p00 -i.bak -le "s/-\n//gs;s/([^!\?\.\"\'\`])\n/\1 /gs;" myfile.txt

    This will remove newline characters at the end of lines that do NOT end in a period, question mark, exclamation point or some form of quote. However, prior to removing those newline characters, it removes any newline character preceded by a hyphen as well as removing the hyphen.

    It works great. Thanks Perl Monks!