P is for Practical | |
PerlMonks |
Re: Tie-ing hashes clobbers databy demerphq (Chancellor) |
on Apr 08, 2002 at 15:06 UTC ( [id://157454]=note: print w/replies, xml ) | Need Help?? |
Couple of points. A cyclic or self-referential structure will break your Tie. Second in the _write sub you are making a _copy_ of the hash. This may or may not be what you want to do. But I think the heart of your problem is here: and here This line sets the $ret value to be equal to the glob *data which was just overwritten by you. (ok, so you ignore the $ret and use the global var \%data, but that was just overwritten so... Same dif.) So its the copy semantics in the _write and _read subs that are causing you trouble. Change them to use scalar refs and not globs and the problem will go away. Oh and lose the shallow copy in _read its misleading and unnecessary. UPDATE A question: Why are you mixing proper method calls and procedural calls? _write() is a method, but you call it as a procedure. This means it wont be overidable in a subclass...
Yves / DeMerphq
In Section
Seekers of Perl Wisdom
|
|