18:14 >perl -wE "my $s = qq[\n\n\n]; my $t = $s =~ s{$}{}gmr; say $s eq $t;" 1 18:14 > #### #! perl use strict; use warnings; my $s = "a\n\n\nb"; my $t = $s =~ s{^\s*?$}{}gmr; printf "%s\n", $s eq $t ? 'success' : 'fail'; print ">$s<\n"; print "[$t]\n"; #### 18:29 >perl 902_SoPW.pl fail >a b< [a b] 18:29 > #### ... Guessed: match at offset 0 2 <%n%nb> | 1:MBOL(2) 2 <%n%nb> | 2:MINMOD(3) 2 <%n%nb> | 3:STAR(5) 2 <%n%nb> | 5: MEOL(6) 2 <%n%nb> | 6: END(0) Match possible, but length=0 is smaller than requested=1, failing! POSIXD[\s] can match 1 times out of 1... 3 <%nb> | 5: MEOL(6) 3 <%nb> | 6: END(0) Match successful! ...