$ perl sub ctx { print wantarray ? "list" : defined wantarray ? "scalar" : "void" } @x = (1); print "map:"; map ctx, @x; print "\ngrep:"; grep ctx, @x; print "\nfor:"; ctx for @x; __END__ map:list grep:scalar for:void