You actually pass the CODEREF into the constuctor, instead of using a soft reference.my $collection = Collection->new({ 'sorter' => \&Sort::mysorter }); ... sub new { my ($self, $options) = @_; . . . $self->{sorter} = $options->{sorter}; }
In reply to Re: Passing a reference to a subroutine in a constructor
by tcf22
in thread Passing a reference to a subroutine in a constructor
by DrSax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |