Brian Behlendorf <brian@organic.com> writes:
>> foreach $i (@array) {
>> $command = "(q~$reply_addr~ =~ $i)";
>> $result = 1, last if (eval $command);
>> }
Why isn't this just:
foreach $i (@array) {
($regex) = ($i =~ m%^/(.*)/$%);
$result = 1, last if ($reply_addr =~ /$regex/);
}
and skip the need for the eval in the first place? eval is evil and
should be avoided where possible. This will cause majordomo to blow major
chunks if the provided regex is invalid, but that's at least semi-trusted
data.
Under Perl 5, you could just use:
eval { $result = 1, last if ($reply_addr =~ /$regex/) };
using the error catching form of eval (which is totally different than a
string eval) and then check $@, but I'm not sure if this works under Perl
4.
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Follow-Ups:
References:
|
|