in reply to Evaluate arbitrary boolean expressions

It looks like you want something that is true or false when used in boolean context (meaning, && and || work as expected) and is the string "true" or "false" when used in string context. Do note that perl doesn't have a specific boolean type, but uses either strings or numbers instead. You can obtain what (I think) you want with an overloaded object. I got lazy so what I did is use the code of boolean and replaced the "overload" call with:

use overload '0+' => sub { ${$_[0]} }, '""' => sub { ${$_[0]} ? "true" : "false"}, '!' => sub { ${$_[0]} ? $false : $true }, fallback => 1;
Then the return value of true and false can be used a string. There are some possible issues though, the string "false" is not empty, so it is actually true, and the string "true" turns into the number 0 so it will be different from the number you may get from true() (which is 1):
use boolean; $\ = $/; my $false = false; print "\$false is $false" unless $false; my $copy = $false; print '$copy is also false' if not $copy; my $str_false = "$false"; print '$str_false is true?' if $str_false; print 'But equal to false' if $str_false eq $false; my $true = true; my $str_true = "$true"; print '$str_true is true but != from true' if $str_true and ($str_true + != true); print "The value of this test is: ", boolean(true||false);
$false is false $copy is also false $str_false is true? But equal to false $str_true is true but != from true The value of this test is: true
It kind of works as long as you do not try to convert the values to a string or a number, and then use them again as boolean. The best solution IMHO would rather be to translate the value to the boolean string whenever you want to print it, and keep the number otherwise, with sub to_bool_str { $_[0] ? "true" : "false" }; print "1 is ", to_bool_str (1);