| Subject: | Evaluate an operator given as a string |
|---|---|
| From: | koren.amit.perl@xxxxxxxxx (Amit Koren) |
| Date: | Wed, 30 Jul 2008 17:43:02 +0300 |
| Newsgroups: | perl.beginners |
Hi all.
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;
if ($x $sign $y) { # want it to be treated as: if ($x >= $y)
...do something...
}
}
Thanks, Amit.
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: rand(), Rob Dixon |
|---|---|
| Next by Date: | Re: Evaluate an operator given as a string, Peng Kyo |
| Previous by Thread: | How to get a computed string to act as a re in if statement, Mike Martin |
| Next by Thread: | Re: Evaluate an operator given as a string, Peng Kyo |
| Indexes: | [Date] [Thread] [Top] [All Lists] |