Ronald J. Kimball [Tue, 6 Dec 2005 09:56:12 +0000 (04:56 -0500)]
Message-ID: <
20051206145612.GA94530@penkwe.pair.com>
p4raw-id: //depot/perl@26278
$whoami .= "[$$]" if our $lo_pid;
- $mask =~ s/(?<!%)%m/$!/g;
+ if ($mask =~ /%m/) {
+ my $err = $!;
+ # escape percent signs if sprintf will be called
+ $err =~ s/%/%%/g if @_;
+ # replace %m with $err, if preceded by an even number of percent signs
+ $mask =~ s/(?<!%)((?:%%)*)%m/$1$err/g;
+ }
+
$mask .= "\n" unless $mask =~ /\n$/;
$message = @_ ? sprintf($mask, @_) : $mask;