sub my_grep($selector, *@list) { given $selector { when Rule { ... } when Code { ... } when Hash { ... } # etc. } } given want { when Scalar {...} # called in scalar context when List {...} # called in list context when Lvalue {...} # expected to return an lvalue when 2 {...} # expected to return two values # ... }# The want function returns an object that contains information about the context in which the current block, closure, or subroutine was called.