Avoid vivifying the overload::StrVal subroutine, its glob, or its stash.
This is done in the same way as the existing avoidance of vivification of
utf8::is_utf8 and utf8::downgrade. However, the check has to be made at
runtime, whereas the utf8-related ones are checked at load time, because
the utf8 ones are built into the perl core (only absent pre perl 5.8)
but overload is a separate module that can be loaded later.
}
else
{
- $arg = defined(&overload::StrVal) ? overload::StrVal($arg) : "$arg";
+ no strict "refs";
+ $arg = exists($::{"overload::"}) &&
+ exists(*{$::{"overload::"}}{HASH}->{"StrVal"}) &&
+ defined(*{*{$::{"overload::"}}{HASH}->{"StrVal"}}{CODE}) ?
+ &{"overload::StrVal"}($arg) : "$arg";
}
}
if ( defined($arg) ) {
-BEGIN { print "1..2\n"; }
+BEGIN { print "1..3\n"; }
our $has_is_utf8; BEGIN { $has_is_utf8 = exists($utf8::{"is_utf8"}); }
our $has_dgrade; BEGIN { $has_dgrade = exists($utf8::{"downgrade"}); }
+our $has_strval; BEGIN { $has_strval = exists($overload::{"StrVal"}); }
use Carp;
+sub { Carp::longmess() }->(\1);
print !(exists($utf8::{"is_utf8"}) xor $has_is_utf8) ? "" : "not ", "ok 1\n";
print !(exists($utf8::{"downgrade"}) xor $has_dgrade) ? "" : "not ", "ok 2\n";
+print !(exists($overload::{"StrVal"}) xor $has_strval) ? "" : "not ", "ok 3\n";
1;
-BEGIN { print "1..1\n"; }
+BEGIN { print "1..2\n"; }
our $has_utf8; BEGIN { $has_utf8 = exists($::{"utf8::"}); }
+our $has_overload; BEGIN { $has_overload = exists($::{"overload::"}); }
use Carp;
+sub { Carp::longmess() }->(\1);
print !(exists($::{"utf8::"}) xor $has_utf8) ? "" : "not ", "ok 1\n";
+print !(exists($::{"overload::"}) xor $has_overload) ? "" : "not ", "ok 2\n";
1;
L<Carp> has been upgraded from version 1.31 to 1.32.
-Carp now avoids some unwanted Unicode warnings on older Perls; doesn't
-affect behaviour with current Perl.
+Carp now won't vivify the C<overload::StrVal> glob or subroutine or the
+C<overload> stash.
+It also avoids some unwanted Unicode warnings on older Perls (which
+doesn't affect behaviour with current Perl).
=item *