Perhaps I am misunderstanding the basic usage of wantarray, but it seems that the void/scalar/list context of a subroutine call propagates to sub-subroutine calls. Is there any way to avoid this, or to force a subroutine call to be executed in void context? For example, consider this code:
sub test {
unless (defined wantarray) {
print "test: wantarray is undefined\n";
} elsif (wantarray) {
print "test: wantarray is true\n";
} else {
print "test: wantarray is false\n";
}
}
sub test2 {
test();
}
my @t = test2();
Executing this prints the statement "test: wantarray is true". However, I would like a way to call test() from within test2(), and force void context. Is this possible?