#!/usr/bin/perl -w 
use strict;
use Text::Format;

# suck it all in from current window.
my $string; while (<>) { $string .= $_; }

# tweak to your desires.
my $text = new Text::Format(justify=>1, firstIndent=>0, leftMargin=>0);

# split string on paragraphs.
my @paragraphs = split(/\n\n/, $string);

# and send it back out.
print $text->paragraphs(@paragraphs);