in reply to Re: Passing a reference to a subroutine in a constructor
in thread Passing a reference to a subroutine in a constructor
or...my $collection = Collection->new({ 'sorter' => Sort::mysorter }); sub new { my ($self, $options) = @_; . . . $self->{sorter} = \&$options->{sorter}; }
When I get to :my $collection = Collection->new({ 'sorter' => \&Sort::mysorter }); sub new { my ($self, $options) = @_; . . . $self->{sorter} = $options->{sorter}; }
or $self->sorter->($stuffToSort); I get the same results.$self->sorter($stuffToSort);
DrSax
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Passing a reference to a subroutine in a constructor
by bobn (Chaplain) on Aug 23, 2003 at 02:38 UTC |