#!/usr/bin/perl -w use strict; use CGI qw(:standard -debug); # Perlmonks.org Poster, by David Caughell, grasp_the_sun@yahoo.co.uk # Converts simple text into text that can be cut and paste into PM posts print "Content-type: text/plain\n\n"; my $text = param('FPost'); my @sections = split('code'.'>', $text); # get rid of leftovers from code tags for (@sections) { chop if /\/$/; chop if /<$/; } for (0 .. $#sections) { unless ($_ % 2) { my @lines = split /\n/, $sections[$_]; my @paragraphs = (''); for (@lines) { if (length $_ <= 1) { push(@paragraphs,'') if length($paragraphs[$#paragraphs]); } $paragraphs[$#paragraphs] .= $_ if length $_ > 1; } pop(@paragraphs) unless length $paragraphs[$#paragraphs]; print "

\n$_\n

\n\n" for @paragraphs; } else { print '\n$sections[$_]\n\n"; } }