Re: Event Handling
- From: "A. Pagaltzis" <pagaltzis gmx de>
- To: gtk-perl-list gnome org
- Subject: Re: Event Handling
- Date: Fri, 5 Aug 2005 17:25:12 +0200
* muppet <scott asofyet org> [2005-08-04 22:35]:
sub foo_event {
my ($item, $event) = @_;
my $handler = $foo_event_dispatch{$event->type};
return $handler
? $foo_event_dispatch{$event->type}->($item, $event)
: FALSE;
}
sub foo_event {
my ($item, $event) = @_;
my $handler = $foo_event_dispatch{$event->type};
return $handler ? $handler->($item, $event) : FALSE;
}
Or even cutely hacked:
sub foo_event {
my ($item, $event) = @_;
($foo_event_dispatch{$event->type} || return FALSE)->($item, $event);
}
Or taking advantage of the fact that you can `goto` a coderef:
sub foo_event {
my ($item, $event) = @_;
goto &{ $foo_event_dispatch{$event->type} || return FALSE };
}
Err, okay, Iâll stop now.
Regards,
--
#Aristotle
*AUTOLOAD=*_=sub{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]