as reported by Tim Bunce. Add a note to this effect in perlfunc,
and regression tests for it.
p4raw-id: //depot/perl@22651
=item wantarray
-Returns true if the context of the currently executing subroutine is
-looking for a list value. Returns false if the context is looking
-for a scalar. Returns the undefined value if the context is looking
-for no value (void context).
+Returns true if the context of the currently executing subroutine or
+eval() block is looking for a list value. Returns false if the context is
+looking for a scalar. Returns the undefined value if the context is
+looking for no value (void context).
return unless defined wantarray; # don't bother doing more
my @a = complex_calculation();
#!./perl
-print "1..9\n";
+print "1..12\n";
sub context {
my ( $cona, $testnum ) = @_;
my $conb = (defined wantarray) ? ( wantarray ? 'A' : 'S' ) : 'V';
print +($c == 2) ? "ok 9\n" : "not ok 9\t# <$c>\n";
}
+my $qcontext = q{
+ $q = (defined wantarray) ? ( wantarray ? 'A' : 'S' ) : 'V';
+};
+eval $qcontext;
+print $q eq 'V' ? "ok 10\n" : "not ok 10\n";
+$a = eval $qcontext;
+print $q eq 'S' ? "ok 11\n" : "not ok 11\n";
+@a = eval $qcontext;
+print $q eq 'A' ? "ok 12\n" : "not ok 12\n";
+
1;