castaway has asked for the wisdom of the Perl Monks concerning the following question:
*goes off to think of another way to do it*$Commands{'who'} = [ { 'pattern' => '^who (.+)$', #' 'mudindex' => 1, 'commandi2' => sub { @args = ($1, 'who'); print Dumper(\@args) +;}, 'commandi3' => sub { @args = ('who-req', getUser(), $1); print + Dumper(\@rgs);}, 'syntax' => 'who <mudname>' }, { 'pattern' => '^who$', #' 'command' => sub { who_local($userid); }, 'syntax' => 'who' }]; .... my @command = @{$Commands{$com}}; my @args = (); foreach my $commands (@command) { debug("commands: " . Dumper($commands)); ... if(my @res = $input =~ /$commands->{'pattern'}/) { debug("results: " . Dumper(\@res)); if($commands->{'mudindex'}) { ... $commands->{'commandi2'}->(); debug("ARGS: " . Dumper(\@args)); my $result = $i2->send($Users{$userid}{'user'}, @args);
C.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using $1,$2 etc in closures..
by chromatic (Archbishop) on Mar 07, 2003 at 21:23 UTC | |
|
Re: Using $1,$2 etc in closures..
by castaway (Parson) on Mar 07, 2003 at 22:23 UTC | |
|
Re: Using $1,$2 etc in closures..
by grantm (Parson) on Mar 07, 2003 at 22:14 UTC | |
by Elian (Parson) on Mar 07, 2003 at 22:23 UTC | |
by grantm (Parson) on Mar 08, 2003 at 01:25 UTC | |
|
Re: Using $1,$2 etc in closures..
by zengargoyle (Deacon) on Mar 08, 2003 at 02:18 UTC | |
|
Re: Using $1,$2 etc in closures..
by Elian (Parson) on Mar 25, 2003 at 17:40 UTC |