Problems? Is your data what you think it is? | |
PerlMonks |
Re: dualvar for a reference-string combinationby james2vegas (Chaplain) |
on Jul 17, 2011 at 19:01 UTC ( [id://914991]=note: print w/replies, xml ) | Need Help?? |
Your object is going to get numified, so it will try and numify the reference (usually to 0, since it ill start with ARRAY or HASH). Perhaps it would be better to set numeric part of dualvar the Hash::Util::FieldHash::id function, register your object (again, with Hash::Util::FieldHash), and use id_2obj to get the object back. Something like:
You could also overload the '0+' operator to return the id of your object. UPDATE: Of course, if you control the object, as per Corion's solution, you could just overload numification and stringification on your object instead. In the case of objects created by other classes, something like this would work: If you are on a Perl less than 5.10, you should use Hash::Util::FieldHash::Compat instead, which is a drop-in replacement for Hash::Util::FieldHash which uses a different method on Perl's before 5.10 and just redirects to Hash::Util::FieldHash on 5.10+.
In Section
Seekers of Perl Wisdom
|
|