Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to prevent references from stringifying?

by Jenda (Abbot)
on Oct 03, 2004 at 18:58 UTC ( [id://396040]=note: print w/replies, xml ) Need Help??


in reply to How to prevent references from stringifying?

I think you might be able to do it using autobox and overload. Something like this I think:

package REF; use overload q("") => sub { die "Attempt to stringify reference" }; package main; use autobox 'REF' => 'REF', DEFAULT => undef; ...
You need at least perl 5.8.1 for this though. That's why I can't test the code myself. (I should update one of these days ...)

Jenda
We'd like to help you learn to help yourself
Look around you, all you see are sympathetic eyes
Stroll around the grounds until you feel at home
   -- P. Simon in Mrs. Robinson

Replies are listed 'Best First'.
Re^2: How to prevent references from stringifying?
by xmath (Hermit) on Oct 03, 2004 at 20:46 UTC
    I just took a quick look at autobox, and in particular the patch it requires to be applied to perl... It seems it only enables method calls on non-objects, but it does not appear to extend other object-qualities such as overloading to non-objects.

    So this trick wouldn't work afaict.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-20 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found