Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: How to prevent references from stringifying?

by xmath (Hermit)
on Oct 03, 2004 at 14:57 UTC ( #396016=note: print w/ replies, xml ) Need Help??


in reply to How to prevent references from stringifying?

I just checked the perl source. I don't see any way of doing this for general references without patching perl. The good news is that's it's easy to patch, so if you're comfortable with recompiling your perl to debug your problem, it's an option.

For perl 5.8.5:

--- sv.c.org 2004-07-12 23:44:41.000000000 +0200 +++ sv.c 2004-10-03 16:54:08.000000000 +0200 @@ -3126,2 +3126,3 @@ } + Perl_croak(aTHX_ "Stringification of reference disallowed"); tsv = NEWSV(0,0);

This still allows stringification of compiled regexen, or when overloading is in place. If you want to disallow stringification in those cases too (so, for all references), you can instead do:

--- sv.c.org 2004-07-12 23:44:41.000000000 +0200 +++ sv.c 2004-10-03 16:56:34.000000000 +0200 @@ -3001,2 +3001,3 @@ SV* tmpstr; + Perl_croak(aTHX_ "Stringification of reference disallowed"); if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,string)) &&

UPDATE: Just in case you're unfamiliar with applying a patch: unpack the perl 5.8.5 source, save one of the above snippets as "patchfile", execute (in the unpacked perl dir) the following command: patch < path/to/patchfile and then compile perl normally


Comment on Re: How to prevent references from stringifying?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://396016]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-07-12 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (238 votes), past polls