in reply to Re: How to remove white space and more than a particular number of new lines!
in thread How to remove white space and more than a particular number of new lines!

Thank You mr_mischief , it helped me a lot...

but this code is affecting all the lines, I want to keep a line as it is if it contains anything other than white space and tabs.

For example I am changing the input and output to this,

Input,

TEST1 fgdfgb Test2 dlfgndkflgbn test3 /,g;dhjzmpa h7rg tRruber Test4 ';gfojmd ofimt lj kjbkhb The Product Manager is a deep expert on specific feature(s), service(s +) or interface(s) that Mimecast provides or sells. This could be a s +ervice delivered through the cloud, or installable software that cust +omers will use on their computers, SmartPhones, tablets and similar d +evices. For each product under your remit, you will have a good understanding +of the competitors in the market and their pricing, as well as the re +levance of the feature to IT administrators, users and customers. Yo +u will use this knowledge to formulate a roadmap of feature enhanceme +nts or, if required, the development of entirely new products and ser +vices. If this sounds like you, then please read onÂ….. You will be required to spend time sharing ideas and product concepts +with customers to gauge feedback, honing the feature pitch, and using + this information to assist the Product Director with pricing deliber +ations. dfgdfg Your role will see you managing development through the entire develop +ment lifecycle, whereafter you will be responsible for launching impr +ovements to Mimecast internally on a global scale. You will be comfo +rtable assisting with the authoring of collateral for web-sites, prin +table assets and to be integrated into appropriate media packs.

Desired output,

TEST1 fgdfgb Test2 dlfgndkflgbn test3 /,g;dhjzmpa h7rg tRruber Test4 ';gfojmd ofimt lj kjbkhb The Product Manager is a deep expert on specific feature(s), service(s +) or interface(s) that Mimecast provides or sells. This could be a se +rvice delivered through the cloud, or installable software that custo +mers will use on their computers, SmartPhones, tablets and similar de +vices. For each product under your remit, you will have a good understanding +of the competitors in the market and their pricing, as well as the re +levance of the feature to IT administrators, users and customers. You + will use this knowledge to formulate a roadmap of feature enhancemen +ts or, if required, the development of entirely new products and serv +ices. If this sounds like you, then please read onÂ….. You will be required to spend time sharing ideas and product concepts +with customers to gauge feedback, honing the feature pitch, and using + this information to assist the Product Director with pricing deliber +ations. dfgdfg Your role will see you managing development through the entire develop +ment lifecycle, whereafter you will be responsible for launching impr +ovements to Mimecast internally on a global scale. You will be comfo +rtable assisting with the authoring of collateral for web-sites, prin +table assets and to be integrated into appropriate media packs.

Many thanks,

Replies are listed 'Best First'.
Re^3: How to remove white space and more than a particular number of new lines!
by graff (Chancellor) on Apr 14, 2014 at 02:24 UTC
    You were shown two alternatives. Which one did you use? (Hint: You must copy/paste directly from the shell window where you ran the command.) What actual output did you get? (Again, use copy/paste.)

    BTW, it's not really clear that the "desired output" is consistent with the OP description of what you're trying to do. Please be more explicit in the explanation, or more careful about presenting the "desired output".

    Also, it looks like your input contains some non-ASCII characters. Do you know what sort of character encoding is being used? If it's UTF-8, you'll want to add '-C31' as the first command-line option on the perl command line that mr_mischief gave you (i.e. perl -C31 -e … (but if it's something other than UTF-8, you'll want to handle encoding conversion).