Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

“Schweee-e-ee-t!”   An extremely elegant solution.

++   ++   ++   ...

And, just for completeness, just for the “technically confused curious” passers-by (however many years from now ...) about “what in the heck a ‘closure’ is,” and with no attempt to steal anyone’s thunder:

A closure is voodoo an advanced technique that Perl makes very easy.   The local variable named $by_value is made to contain a reference to an anonymous sub which was created within a block of code in which a local variable named $self was “visible” to it, and in which it was known that this $self would continue to exist (with its then-present value) for the duration over which it will be needed.   (Namely:   “the lifetime of sub sort_hash_ref_keys_by_value.”)   This anonymous sub ... a “closure” ... will, rather magically, be able to “see” $self too, and can therefore refer to it in addition to $a and $b.   Each time the sort verb invokes this anonymous function, that function will magically be able to “see” $self, as though the sort verb, itself, were also located in the same block of source-code in which the closure-sub is defined.   The next best thing to being in two places at one time.

Masterful.   Brilliant.

In reply to Re^2: How can I access object data in a user defined sort cmp function? by sundialsvc4
in thread How can I access object data in a user defined sort cmp function? by tkguifan

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2022-05-23 11:01 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (81 votes). Check out past polls.