ossp-pkg/string-divert/Divert.pm 1.2 -> 1.3
--- Divert.pm 2003/05/23 11:09:56 1.2
+++ Divert.pm 2003/05/23 20:37:32 1.3
@@ -185,7 +185,11 @@
foreach my $chunk (@{$self->{chunks}}) {
if (ref($chunk)) {
my $prefix = '';
- if ($string =~ m|([^\n]*)(\r?\n)*$|s) {
+ # check for existing prefix
+ # (keep in mind that m|([^\n]+)$|s _DOES NOT_
+ # take a possibly existing terminating newline
+ # into account, so we really need an extra match!)
+ if ($string =~ m|([^\n]+)$|s and $string !~ m|\n$|s) {
$prefix = $1;
$prefix =~ s|[^ \t]| |sg;
}
|
|