Indeed. You can use
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
statement. You are actually saying
which propagates test2's context. Write
instead.