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();