http://www.perlmonks.org?node_id=1208759


in reply to Passing logical operators on as content of scalar

Really not sure whether this is any better, but you could use (string) eval, as shown here under the debugger:
DB<1> $number1 = 2011; DB<2> $number2 = 2011; DB<3> $selectioncriterium = '==' DB<4> print "number1 is ", eval "$number1 $selectioncriterium $num +ber2" ? "" : "not ", "equal to $number2\n"; number1 is equal to 2011 DB<5> print "number1 is ", eval "$number1 $selectioncriterium 7842 +"? "" : "not ", "equal to 7842\n"; number1 is not equal to 7842

Replies are listed 'Best First'.
Re^2: Passing logical operators on as content of scalar
by gm40 (Initiate) on Feb 09, 2018 at 04:43 UTC
    Thanks for all the help and suggestions. Everything is valuable and has enlightened me.