|Problems? Is your data what you think it is?|
How might I return tied scalar that does not have to be dereferenced as $$scalar?by rr (Sexton)
|on Sep 18, 2002 at 15:03 UTC||Need Help??|
rr has asked for the wisdom of the Perl Monks concerning the following question:
I have a class called 'Datum' that implements the tied scalar interface. This class's constructor returns a tied scalar ref at present. This means that in my code, the returned scalar object must be dereferenced as '$$scalar'.
The $$ dereferencing is the problem.
I would like to write a method, module, C extension, or whatever it takes to have the class's new method return an object that may be used exactly as if it were a scalar, but this new magic variable also accepts method invocation and and supports running my code on STORE FETCH etc. I guess this might even be considered a new variable type, based on scalar.
I know that I can tie the scalar to my Datum class all over my code, but that's very tedious as there are hundreds of them in my programs
Is this possible in perl5? Would I have to write an XS module instead?