in reply to Re: Write to file, after manipulation
in thread Write to file, after manipulation
ibanix wrote:Ugh!sub bot_command { my $command = shift(@_); join_channel($command) if ($command =~ /join/); part_channel($command) if ($command =~ /part/); msg_user($command) if ($command =~ /msg/); .... default($command); }
sub bot_command { local $_ = shift; /join/ ? &join_channel : /part/ ? &part_channel : /msg/ ? &msg_user : &default }
I'm still trying to figure out how a dispatch table worksLike this:
sub join_channel { ... } sub part_channel { ... } sub msg_user { ... } my %dispatch = ( join => \&join_channel, part => \&part_channel, msg => \&msg_user, ); sub bot_command { my $cmd = shift; $dispatch{$cmd} ? &{$dispatch{$cmd}} : &default }
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Write to file, after manipulation
by jdporter (Paladin) on Jan 29, 2003 at 20:06 UTC | |
|
Re: Re: Re: Write to file, after manipulation
by ibanix (Hermit) on Jan 28, 2003 at 22:01 UTC |