When evaluating an expression in a scalar (boolean) context, Perl uses the explicit value 1 as a result if the expression evaluates to true and the empty string
1
Here is how I got around the problem:
my $res = ($a eq $b) *1;
The *1 converts the boolean resulting from ($a eq $b) into a scalar.
*1
($a eq $b)