We don't bite newbies here... much | |
PerlMonks |
Re: Iterating over *any* thing in Perlby Ovid (Cardinal) |
on Dec 03, 2002 at 06:29 UTC ( [id://217141]=note: print w/replies, xml ) | Need Help?? |
Typically (not always), you can inspect the contents of anything, but that depends upon how you define "contents". For example, what do you mean when you say "the content of a closure"? If you wanted, as I believe you were describing, to remove an internal reference to an external object, then you would probably just undef the scalar holding the reference to the closure or have the closure internally undef an unnecessary reference. There's no way (and no need) to peer inside. As for objects, are you referring to a need to iterate over what data structure has been blessed? You can bless hash references, an array references and those are easy to iterate over. However, how would you "iterate" over a code reference or a regex that's been blessed? As for a general function to access each field of an object, there isn't one. This is something that is (and should be!) handled inside of the object's class and is based upon the needs of that particular object. For example, I once found a solution to a thorny problem by blessing integers. One doesn't typically iterate over a single value if you know it's always a single value. Cheers, New address of my CGI Course.
In Section
Seekers of Perl Wisdom
|
|