in reply to Re: Re: eval routines for faster regexp: how-to...
in thread eval routines for faster regexp: how-to...
The nice thing about this is that looks just like a normal function and you don't have to worry about '&' and stuff.sub genFind { my $patt = shift; my $code = "sub find {\n\tmy \$str = shift;\n\t\$str =~/$patt/;\n}; eval $code; die "Error in eval: $@\ncode = $code\n" if $@; } #call genFind ('foo'); $res = find ('barefoot'); #can now call 'find' as function
pike
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Hey, this isn't python :)
by Fletch (Bishop) on Nov 08, 2001 at 18:47 UTC |