Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

namespace::autoclean5.18(3pm) [mojave man page]

namespace::autoclean(3pm)				User Contributed Perl Documentation				 namespace::autoclean(3pm)

NAME
namespace::autoclean - Keep imports out of your namespace SYNOPSIS
package Foo; use namespace::autoclean; use Some::Package qw/imported_function/; sub bar { imported_function('stuff') } # later on: Foo->bar; # works Foo->imported_function; # will fail. imported_function got cleaned after compilation DESCRIPTION
When you import a function into a Perl package, it will naturally also be available as a method. The "namespace::autoclean" pragma will remove all imported symbols at the end of the current package's compile cycle. Functions called in the package itself will still be bound by their name, but they won't show up as methods on your class or instances. This module is very similar to namespace::clean, except it will clean all imported functions, no matter if you imported them before or after you "use"d the pragma. It will also not touch anything that looks like a method, according to "Class::MOP::Class::get_method_list". If you're writing an exporter and you want to clean up after yourself (and your peers), you can use the "-cleanee" switch to specify what package to clean: package My::MooseX::namespace::autoclean; use strict; use namespace::autoclean (); # no cleanup, just load sub import { namespace::autoclean->import( -cleanee => scalar(caller), ); } PARAMETERS
-also => [ ITEM | REGEX | SUB, .. ] -also => ITEM -also => REGEX -also => SUB Sometimes you don't want to clean imports only, but also helper functions you're using in your methods. The "-also" switch can be used to declare a list of functions that should be removed additional to any imports: use namespace::autoclean -also => ['some_function', 'another_function']; If only one function needs to be additionally cleaned the "-also" switch also accepts a plain string: use namespace::autoclean -also => 'some_function'; In some situations, you may wish for a more powerful cleaning solution. The "-also" switch can take a Regex or a CodeRef to match against local function names to clean. use namespace::autoclean -also => qr/^_/ use namespace::autoclean -also => sub { $_ =~ m{^_} }; use namespace::autoclean -also => [qr/^_/ , qr/^hidden_/ ]; use namespace::autoclean -also => [sub { $_ =~ m/^_/ or $_ =~ m/^hidden/ }, sub { uc($_) == $_ } ]; SEE ALSO
namespace::clean Class::MOP B::Hooks::EndOfScope AUTHOR
Florian Ragwitz <rafl@debian.org> CONTRIBUTORS
o Andrew Rodland <andrew@hbslabs.com> o Chris Prather <cprather@hdpublishing.com> o Dave Rolsky <autarch@urth.org> o Felix Ostmann <sadrak@sadrak-laptop.(none)> o Karen Etheridge <ether@cpan.org> o Kent Fredric <kentfredric@gmail.com> o Shawn M Moore <sartak@gmail.com> o Tomas Doran <bobtfish@bobtfish.net> COPYRIGHT AND LICENSE
This software is copyright (c) 2009 by Florian Ragwitz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.18.2 2013-12-14 namespace::autoclean(3pm)

Check Out this Related Man Page

Moose::Cookbook::Snack::Keywords(3pm)			User Contributed Perl Documentation		     Moose::Cookbook::Snack::Keywords(3pm)

NAME
Moose::Cookbook::Snack::Keywords - Restricted "keywords" in Moose VERSION
version 2.0603 DESCRIPTION
Moose exports a number of sugar functions in order to emulate Perl built-in keywords. These can cause clashes with other user-defined functions. This document provides a list of those keywords for easy reference. The 'meta' keyword "use Moose" adds a method called "meta" to your class. If this conflicts with a method or function you are using, you can rename it, or prevent it from being installed entirely. To do this, pass the "-meta_name" option when you "use Moose". For instance: # install it under a different name use Moose -meta_name => 'moose_meta'; # don't install it at all use Moose -meta_name => undef; Moose Keywords If you are using Moose or Moose::Role it is best to avoid these keywords: extends with has before after around super override inner augment confess blessed Moose::Util::TypeConstraints Keywords If you are using Moose::Util::TypeConstraints it is best to avoid these keywords: type subtype class_type role_type maybe_type duck_type as where message optimize_as inline_as coerce from via enum find_type_constraint register_type_constraint Avoiding collisions Turning off Moose To remove the sugar functions Moose exports, just add "no Moose" at the bottom of your code: package Thing; use Moose; # code here no Moose; This will unexport the sugar functions that Moose originally exported. The same will also work for Moose::Role and Moose::Util::TypeConstraints. Sub::Exporter features Moose, Moose::Role and Moose::Util::TypeConstraints all use Sub::Exporter to handle all their exporting needs. This means that all the features that Sub::Exporter provides are also available to them. For instance, with Sub::Exporter you can rename keywords, like so: package LOL::Cat; use Moose 'has' => { -as => 'i_can_haz' }; i_can_haz 'cheeseburger' => ( is => 'rw', trigger => sub { print "NOM NOM" } ); LOL::Cat->new->cheeseburger('KTHNXBYE'); See the Sub::Exporter docs for more information. namespace::autoclean and namespace::clean You can also use namespace::autoclean to clean up your namespace. This will remove all imported functions from your namespace. Note that if you are importing functions that are intended to be used as methods (this includes overload, due to internal implementation details), it will remove these as well. Another option is to use namespace::clean directly, but you must be careful not to remove "meta" when doing so: package Foo; use Moose; use namespace::clean -except => 'meta'; # ... SEE ALSO
Moose Moose::Role Moose::Utils::TypeConstraints Sub::Exporter namespace::autoclean namespace::clean AUTHOR
Moose is maintained by the Moose Cabal, along with the help of many contributors. See "CABAL" in Moose and "CONTRIBUTORS" in Moose for details. COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-28 Moose::Cookbook::Snack::Keywords(3pm)
Man Page