Indeed. You can use
scalar foo(...) to force foo to be called in scalar context. I think using the function on a line by itself, without using the return value, will give void context. The reason it is not the case in your example is because test() is the
last line in the function test2, and is an implicit
return statement. You are actually saying
return test() which propagates test2's context. Write
test(); return; instead.