in reply to Text::Autoformat not behaving correctly

It formatted the first paragraph. To get the desired results (that is, to format all the paragraphs), just add "all=>1" to the options:
#!/usr/bin/perl -w use strict; use Text::Autoformat; undef $/; my $text = <>; print autoformat($text, {left=>20, right=>60, all=>1});

Replies are listed 'Best First'.
Re: Re: Text::Autoformat not behaving correctly
by BMaximus (Chaplain) on Jun 22, 2001 at 07:48 UTC
    Thanks. Apparently the lack of a definition of what constitutes a paragraph to Text::Autoformat has gotten to me. You would think that according to the module's documentation that it would be able to discern what a paragraph is and what isn't. Its not really clear in the paragraph section.

    Quote:
    The fundamental task of the autoformat subroutine is to identify and rearrange independent paragraphs in a text. Paragraphs typically consist of a series of lines containing at least one non-whitespace character, followed by one or more lines containing only optional whitespace. This is a more liberal definition than many other formatters use: most require an empty line to terminate a paragraph. Paragraphs may also be denoted by bulleting, numbering, or quoting (see the following sections).

    Once a paragraph has been isolated, autoformat fills and re-wraps its lines according to the margins that are specified in its argument list. These are placed after the text to be formatted, in a hash reference:


    ++ to you BikeNomad

    BMaximus
      If you can get a copy of the latest Perl Journal (#20), Damian Conway's written an article about Text::Autoformat that discusses this. Quote: "autoformat understands all these notions of a paragraph. Even when they're all used at once. Even when they're used inside one another (for example, quoting a list of bulleted points)."

      -- Frag.