[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] converting a scalar containing an operator into anoperator



pr1@club-internet.fr (Philippe de Rochambeau) writes:
}How do you make MacPerl evaluate an operator placed in a scalar? For example,
}
}$op = ">";
}$num1 = 10;
}$num2 = 2;
}
}#Here I need a function to convert $op to >
}if ($num1 $op $num2)
}{
}...
}}

Use eval.  This seems to work correctly for various $op's:

#!perl

$op = ">";
$num1 = 10;
$num2 = 2;
if(eval "$num1 $op $num2") {
 print "is\n";
} else {
 print "isn\'t\n";
}

}
}Many thanks.
}
}Philippe de Rochambeau
}
}______________________________________________________________________________
}Philippe de Rochambeau
}pr1@club-internet.fr
}
}
}
}***** Want to unsubscribe from this list?
}***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch


--------
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693
Greenbelt, MD 20770
schinder@pjstoaster.pg.md.us


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch