http://qs321.pair.com?node_id=1229961


in reply to can has ELI5 namespace::autoclean pls?

If you don't clean your imports using something like namespace::autoclean or namespace::clean, then they will remain and be callable as methods on your objects. So something like the following will work and issue a warning with your object stringified:

package Foo; use Moose; use Carp; Foo->new->carp;

This is usually not harmful, although it can be unexpected or allow people to accidentally call things in unusual ways. Cleaning your imports also allows you to re-use those imported sub names as method, such as for attributes. That means that the following will work:

package Foo; use Moose; use namespace::autoclean; has after => (is => 'ro', default => 'yay'); print "It worked " . Foo->new->after;

Normally, after would be one of Moose's helpers that creates a method modifier, but cleaning it using namespace::autoclean allows an attribute with the same name to be created.