Re: equality as a variable



anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel) wrote in
news:dhjufn$801$1@xxxxxxxxxxxxxxxxxxxxxxxxx:

> A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx> wrote in comp.lang.perl.misc:
>> Brian Wakem <no@xxxxxxxxx> wrote in
>> news:3q58ibFd6ikpU1@xxxxxxxxxxxxxx:
>>
>> > Shiraz wrote:
>> >
>> >> i need to put the equality in an if statement as a variable
....

>> Hmmm ... Sorry, I am going to go with hash based solution:

....

> I'd use the hash *and* eval:
>
> my %handlers = map { $_ => eval "sub { \$_[0] $_ \$_[ 1] }" }
> qw( > < >= <= == != <=>),
> # qw( gt lt ge le eq ne cmp),
> ;
>
> That string-eval is perfectly safe, everything comes from inside the
> source.

I always type too much :))

Thank you.

Sinan.

--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
.