For the one caller using the global variable, instead pass the message in as
a function parameter.
local $SIG {__WARN__} = sub {$w .= join "" => @_};
use warnings 'all';
ref $code ? &$code : eval $code;
- _ok !$w, $name // ($Message ? "$Message (did not warn)"
- : "Did not warn"),
- "Got warning '$w'";
+ _ok !$w, $name, "Got warning '$w'";
}
1;
{
- local $Message = '"1" is not \s';
- may_not_warn sub {ok ("1\n" x 102) !~ /^\s*\n/m};
+ my $message = '"1" is not \s';
+ may_not_warn sub {ok ("1\n" x 102 !~ /^\s*\n/m, $message)}, "$message (did not warn)";
}