in reply to using re 'eval' for varibable math

That's not a regexp, so the re pragma won't help here. However, the built-in eval function will:

#!C:/perl/bin/perl.exe use warnings; use strict; my $question = "67.35 >= 50 && 67.35 < 80"; my $ans = eval $question; die("Compile error: $@\n") if $@; print("ans = ", ($ans ? 'true' : 'false'), "\n");

Beware including user-supplied data in an eval. Users are sometimes malicious or supply unexpected data.

Replies are listed 'Best First'.
Re^2: using re 'eval' for varibable math
by Anonymous Monk on Apr 19, 2005 at 15:03 UTC
    Much easier....That works great. Thanks!