use strict; use warnings; 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);
$txt;
}
my $test = <<'--';
One fish
Two fish
Red fish
Blue fish
--
print ubb_txt ($test), "\n";
__END__
One fish
Two fish
Red fish
Blue fish