ok($this eq $that, $test_name);
This simply evaluates any expression ($this eq $that is just a simple example) and uses that to determine if the test succeeded or failed. A true expression passes, a false one fails. Very simple.So it's not exactly what you describe.
Additionally a list in scalar context returns it's last value not the number of it's elements. So your explanation of what happens after the keys function is not right.
$ perl -e 'print scalar (1, "a"), "\n";' a