karun.jiju has asked for the wisdom of the Perl Monks concerning the following question:

I used the module Text::Format to format the text after 70 columns. The text used for formating is "The Email Issue (matter getting shattering/ numbers coming in between etc..) was addressed to Jiju and he is looking into this with highest priority. This will be fixed ASAP." But the output after formatting is a bit different than expected.In the output after the first two words ie.,after 'The Email Issue' the next words are coming in new line.The output and code is given below

Output is "The Email Issue
(matter getting shattering/ numbers coming in between
etc..) was addressed to jiju and he is looking into this with highest
priority. This will be fixed ASAP."

use Text::Format; $body = "The Email Issue (matter getting shattering/ numbers coming in between etc..) was addressed to jiju and he is looking into this with + highest priority. This will be fixed ASAP."; $body = Text::Format->new({columns => 70,firstIndent => 0})->form +at($body); print $body;

The output i needed is each line should contain 70 characters that is
"The Email Issue (matter getting shattering/ numbers coming in between
etc..) was addressed to Jiju and he is looking into this with highest
priority. This will be fixed ASAP."

Replies are listed 'Best First'.
Re: text formatting
by ikegami (Patriarch) on Feb 16, 2010 at 09:15 UTC
    Not for me.
    use Text::Format; $body = "The Email Issue (matter getting shattering/ numbers coming in + between etc..) was addressed to jiju and he is looking into this wit +h highest priority. This will be fixed ASAP."; $body = Text::Format->new({columns => 70,firstIndent => 0})->form +at($body); print $body;
    >perl a.pl The Email Issue (matter getting shattering/ numbers coming in between etc..) was addressed to jiju and he is looking into this with highest priority. This will be fixed ASAP.

    Are you sure it's a space before the opening paren?

      The issue is that while formatting with this code after a few words not after 70 columns but before that the text will split and the next words will come in new line but there will no extra character in between the words to make a new line.

        I doubt that anyone understands what you are saying...

        Here is some advice:

        • Post full code that can be copied/pasted and run. This includes declaring $body
        • Paste the output you get
        • Paste the output you expected

        I did not understand that either. If you want my help and you can't find a means of expressing yourself in English or French, just provide
        • A small piece of runnable code.
        • The output it produces for you.
        • The output you desire from it.
        I should be able to figure out the rest