in reply to Dynamic operators

You could do it using eval.

my $a = 10; my $b = 20; my $op = '>='; if (eval "$a $op $b") { print "true\n"; } else { print "false\n"; }
--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: Dynamic operators
by Juerd (Abbot) on Sep 11, 2002 at 13:03 UTC

    if (eval "$a $op $b") {

    if (eval "\$a $op \$b") {
    Makes life easier.

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.