silently

prevent any output from a block

NAME

silently - prevent any output from a block

SYNOPSIS

use silently;

DESCRIPTION

silently is module that exports a single sub called silently that takes a block to execute. Inside that block, all textual output to *ERR is prevented from actually being sent to STDOUT and STDERR.

Note that if you're only interested in surpressing output from warnings, you should use the quietly statement prefix.

SUBROUTINES

silently

silently { say "hello world" }  # no output

my $captured = silently { note "tis wrong" }
if $captured.err -> $error {
    say "something went wrong: $error";
}

The "silently" subroutine takes a block as a parameter, and runs that block catching all output to $*OUT and $*ERR.

If the output is actually needed for inspection: the subroutine returns an object that provides two methods: out and err, giving the captured output to $*OUT and $*ERR respectively.

AUTHOR

Elizabeth Mattijsen [email protected]

Source can be located at: https://github.com/lizmat/silently . Comments and Pull Requests are welcome.

COPYRIGHT AND LICENSE

Copyright 2020, 2021 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

silently v0.0.4

prevent any output from a block

Authors

  • Elizabeth Mattijsen

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • silently

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.