$ perl sub check_context { # True if ( wantarray ) { print "List context\n"; } # False, but defined elsif ( defined wantarray ) { print "Scalar context\n"; } # False and undefined else { print "Void context\n"; } } my @x = check_context(); # prints 'List context' my %x = check_context(); # prints 'List context' my ($x, $y) = check_context(); # prints 'List context' my $x = check_context(); # prints 'Scalar context' check_context(); # prints 'Void context' __END__ List context List context List context Scalar context Void context