use strict; use CGI; my $query = new CGI; my $text = cleanup_txt( $query->param( 'text' )); print ubb_txt( $text); sub cleanup_txt { my $str = $_[0]; return "" unless ( defined $str ); $str =~ s/[<>"'&|]//gs; } sub ubb_txt { my $txt = shift; return "" unless ( defined $txt); my ($nl) = $txt =~ m{(\cM?\cJ)}; $txt =~ s{$nl$nl}{

}gs if (defined $nl); $txt =~ s{$nl}{
}gs if (defined $nl); }