use strict; my @list = qw/ box cow dog apple ant/; { my $count = 0; sub get_count { return $count } # an inspector as a closure # and another closure sub compare { $count++; return $_[0] cmp $_[1]; } } print sort { compare( $a, $b ) } @list; print "\n"; print get_count();
In reply to Re: Closures and sort
by larsen
in thread Closures and sort
by traveler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |