gleeco has asked for the wisdom of the Perl Monks concerning the following question:
..and then using it later on:$fast = sub { my $match = qq@ return 1 if m!foo!o; @; my $code = eval "sub {$match ; return 0}"; return $code; };
this is a charming trick when it works, but i've only done it with the eval'd sub returning 0 or 1. Has anybody tried this with other return values? Ideally, i'd like it to read:while(<>) { next unless &{$fast}; }
...however, it seems like this is not really working :( attempts to capture the return have set the return value to 'CODE'. what's up with that? any thoughts/hints/experience?$match = qq@ return (\$1,\$2) if m!(foo)(bar)!; @;
dorking hard,
gleeco
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: eval routines for faster regexp: how-to...
by japhy (Canon) on Nov 08, 2001 at 07:29 UTC | |
|
Re: eval routines for faster regexp: how-to...
by stefp (Vicar) on Nov 08, 2001 at 07:47 UTC | |
by chipmunk (Parson) on Nov 08, 2001 at 08:40 UTC | |
by pike (Monk) on Nov 08, 2001 at 14:27 UTC | |
by Fletch (Bishop) on Nov 08, 2001 at 18:47 UTC |