# This would be in a module
sub pager is export {
  run(%*ENV<PAGER>, :in).in
}
# ---

# Allow the user to do this:
{
  temp $*OUT = pager;
  say 10000.rand for ^20;
}

# $*OUT should be reset to STDOUT here the pager pipe should be closed.

say "do other stuff here";