Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: 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.


New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)

In reply to Re: Iterating over *any* thing in Perl by Ovid
in thread Iterating over *any* thing in Perl by Schemer

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (4)
    As of 2021-05-10 07:42 GMT
    Find Nodes?
      Voting Booth?
      Perl 7 will be out ...

      Results (105 votes). Check out past polls.