Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^4: Real life uses for closures.

by DrHyde (Prior)
on Feb 18, 2013 at 11:54 UTC ( #1019332=note: print w/replies, xml ) Need Help??

in reply to Re^3: Real life uses for closures.
in thread Real life uses for closures.

Here's a closure from it ...

$sortsub = sub($$) { $spec->($_[0]->{$field}, $_[1]->{$field}) || $oldsortsub->($_[0], $_[1]) }

Lemme guess - did you just grep the code for /sub {/? :-)

Replies are listed 'Best First'.
Re^5: Real life uses for closures.
by tobyink (Abbot) on Feb 18, 2013 at 20:20 UTC

    I didn't look at the source code at all - I was just referring to the usage examples in the pod.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019332]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-11-25 00:22 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (354 votes). Check out past polls.