http://www.perlmonks.org?node_id=396143


in reply to Re^2: How to prevent references from stringifying?
in thread How to prevent references from stringifying?

Actually, PL_hints is just used at compile-time, not at runtime. But using (PL_curcop->op_private & HINT_STRICT_STRINGIFY) instead should work.

UPDATE: Oh, and a minor note: Perl_warner needs an additional argument that indicates the warning category, like:

if ((PL_curcop->op_private & HINT_STRICT_STRINGIFY) && ckWARN(WARN_MISC)) Perl_warner(aTHX_ packWARN(WARN_MISC), "Stringification of reference disallowed");
or alternatively you could omit the check and use Perl_warn which takes no such argument.