Re: Evaluate an operator given as a string

2008-07-30 Thread John W. Krahn
Amit Koren wrote: Hi all. Hello, I'm trying to pass the operators ">=" or "<=" to a subroutine, and then use it inside an "if" statement. What changes should i apply to the code below to make it work ? my_evaluate ( ">="); sub my_evaluate { my ($sign) = @_; my $x = 10; my $y = 20

Re: Evaluate an operator given as a string

2008-07-30 Thread peng . kyo
On Wed, Jul 30, 2008 at 10:43 PM, Amit Koren <[EMAIL PROTECTED]> wrote: > if ($x $sign $y) { # want it to be treated as: if ($x >= $y) one way, change the line above to: if (eval "$x $sign $y") { ... } -- Regards, Jeff. - [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED]