harsha.reddy has asked for the wisdom of the Perl Monks concerning the following question:
In the following code, in the sub-routine names new(), I have used something like:
_proc => $action1,
_proc => \$action1,
package Engine; use strict; use My::Module; my $action1 = sub { $pkt = shift; #where $pkt is an object of type My:Module:Object my $id = $pkt->get('ID'); #........ #do this #do that... print $id; } sub new { my $class = @_; return bless { _xp => My::Module->new(), _proc => $action1, } }; sub routine { my $s = shift; $s->{_xp}->process(); my @arr = $s->{_xp}->getvalues("packet"); map($action1->($_), @arr); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A way registering an anonymous sub in $self?
by ikegami (Patriarch) on Mar 05, 2010 at 19:00 UTC | |
|
Re: A way registering an anonymous sub in $self?
by BrowserUk (Patriarch) on Mar 05, 2010 at 19:50 UTC |