Problems? Is your data what you think it is? | |
PerlMonks |
RE: RE: RE (tilly) 2: access to my variables from other subsby chromatic (Archbishop) |
on Oct 21, 2000 at 09:08 UTC ( [id://37781]=note: print w/replies, xml ) | Need Help?? |
In a similar situation, I'd use an object. If you need to carry context and variables around, blessing a hash is a pretty convenient way to have a bundle of data that knows which operations it supports.
The beauty there is, depending on your encapsulation paranoia, you still have access to the hash through the reference, so working with its data is as easy as usual. Nesting subroutines is a conceptual no-no in Perl... hard to maintain, hard to debug. The closures route is a little tricky if you're not familiar with functional programming (but can be very useful in other cases). If you can live with enforced lexical context through a reference, you'll be a lot happier with objects.
In Section
Seekers of Perl Wisdom
|
|