Scoped object oriented automatic cleanup
Perl 6
Switch branches/tags
Nothing to show


Build Status Build status

Provides a routine clean that takes an object and an anonymous code block which takes an object that does Cleanable. This basically ensures that your objects can be cleaned after your code block has finished running. Thus it provides an object-oriented clean method (aka destructor).


# A class that needs to close or free resources
class Foo does Cleanable {

  # Guaranteed to be called once the anonymous block finishes execution
  method clean {
    # Close or free resources here

  # The object we need to be cleaned up,

  # The anonymous block
  -> $obj {
    # Do interesting stuff with $obj of type Cleanable


To install it using zef (a module management tool bundled with Rakudo Star):

$ zef install Clean


To run tests:

$ prove -e "perl6 -Ilib"

To run author tests, you need to manually install Test::META:

$ zef install Test::META
$ TEST_AUTHOR=1 prove -e "perl6 -Ilib"


Ahmad M. Zawawi, azawawi on #perl6,


MIT License