Control::Bail - Defer cleanup code

NAME

Control::Bail - Defer cleanup code

SYNOPSIS


    # In the following code:
    # If there was a touchdown there is cheering
    # ...then...
    # The Receiver gets an icepack, but only if he was tackled.
    # ...then...
    # A streaker runs across the field, no matter what.
    # ...then...
    # The Receiver always gets juice, unless the QB was sacked.
    # ...then...
    # The QB always gets taunted, unless there was a touchdown.
    # ...then...
    # If there was no touchdown, the failure is thrown.
    use Control::Bail;
    sub towlboy {
        bail { say "Taunt the QB" }
        Bool.pick or die "sacked!";
        trail { say "Bring Receiver juice" }
        LEAVE { say "Streaker runs across field" }
        bail { say "Bring Receiver icepack" }
        Bool.pick or die "tackled!";
        say "touchdown!";
    }
    towlboy();


AUTHOR

Brian S. Julin

COPYRIGHT

Copyright (c) 2016 Brian S. Julin. All rights reserved.

LICENSE

This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License 2.0.

SEE-ALSO

perl6::(1)

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