Vulnerabilities | |||||
---|---|---|---|---|---|
Version | Suggest | Low | Medium | High | Critical |
0.31 | 0 | 0 | 0 | 0 | 0 |
0.30-TRIAL | 0 | 0 | 0 | 0 | 0 |
0.29 | 0 | 0 | 0 | 0 | 0 |
0.28 | 0 | 0 | 0 | 0 | 0 |
0.27 | 0 | 0 | 0 | 0 | 0 |
0.26 | 0 | 0 | 0 | 0 | 0 |
0.25 | 0 | 0 | 0 | 0 | 0 |
0.24 | 0 | 0 | 0 | 0 | 0 |
0.23 | 0 | 0 | 0 | 0 | 0 |
0.22 | 0 | 0 | 0 | 0 | 0 |
0.21 | 0 | 0 | 0 | 0 | 0 |
0.20 | 0 | 0 | 0 | 0 | 0 |
0.19 | 0 | 0 | 0 | 0 | 0 |
0.18 | 0 | 0 | 0 | 0 | 0 |
0.17 | 0 | 0 | 0 | 0 | 0 |
0.16-TRIAL | 0 | 0 | 0 | 0 | 0 |
0.15 | 0 | 0 | 0 | 0 | 0 |
0.14 | 0 | 0 | 0 | 0 | 0 |
0.31 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform
Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.
Artistic-1.0 - Artistic License 1.0=pod
=encoding UTF-8
=head1 NAME
namespace::autoclean - Keep imports out of your namespace
=head1 VERSION
version 0.31
=head1 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
=head1 DESCRIPTION
When you import a function into a Perl package, it will naturally also be available as a method.
The Cnamespace::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 Lnamespace::clean|namespace::clean, except it will clean all imported functions, no matter if you imported them before or after you Cd the pragma. It will also not touch anything that looks like a method.
If you're writing an exporter and you want to clean up after yourself (and your peers), you can use the C<-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), ); }
=head1 WHAT IS AND ISN'T CLEANED
Cnamespace::autoclean will leave behind anything that it deems a method. For L classes, this the based on the C<get_method_list> method on from the LClass::MOP::Class|metaclass. For non-Moose classes, anything defined within the package will be identified as a method. This should match Moose's definition of a method. Additionally, the magic subs installed by L will not be cleaned.
=head1 PARAMETERS
=head2 -also => [ ITEM | REGEX | SUB, .. ]
=head2 -also => ITEM
=head2 -also => REGEX
=head2 -also => SUB
Sometimes you don't want to clean imports only, but also helper functions you're using in your methods. The C<-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 C<-also> switch also accepts a plain string:
use namespace::autoclean -also => 'some_function';
In some situations, you may wish for a more I cleaning solution.
The C<-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($_) == $_ } ];
=head2 -except => [ ITEM | REGEX | SUB, .. ]
=head2 -except => ITEM
=head2 -except => REGEX
=head2 -except => SUB
This takes exactly the same options as C<-also> except that anything this matches will I be cleaned.
=head1 CAVEATS
When used with L classes, the heuristic used to check for methods won't work correctly for methods from roles consumed at compile time.
package My::Class; use Moo; use namespace::autoclean;
BEGIN { with 'Some::Role' }
with 'Some::Role';
Additionally, method detection may not work properly in L classes in perls earlier than 5.10.
=head1 SEE ALSO
=over 4
=item *
Lnamespace::clean
=item *
L<B::Hooks::EndOfScope>
=item *
Lnamespace::sweep
=item *
LSub::Exporter::ForMethods
=item *
LSub::Name
=item *
LSub::Install
=item *
LTest::CleanNamespaces
=item *
LDist::Zilla::Plugin::Test::CleanNamespaces
=back
=head1 SUPPORT
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=namespace-autoclean> (or L<bug-namespace-autoclean@rt.cpan.org|mailto:bug-namespace-autoclean@rt.cpan.org>).
There is also a mailing list available for users of this distribution, at Lhttp://lists.perl.org/list/moose.html.
There is also an irc channel available for users of this distribution, at L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>.
=head1 AUTHOR
Florian Ragwitz rafl@debian.org
=head1 CONTRIBUTORS
=for stopwords Karen Etheridge Graham Knop Dave Rolsky Kent Fredric Tomas Doran Shawn M Moore Felix Ostmann Andrew Rodland Chris Prather
=over 4
=item *
Karen Etheridge ether@cpan.org
=item *
Graham Knop haarg@haarg.org
=item *
Dave Rolsky autarch@urth.org
=item *
Kent Fredric kentfredric@gmail.com
=item *
Tomas Doran bobtfish@bobtfish.net
=item *
Shawn M Moore cpan@sartak.org
=item *
Felix Ostmann sadrak@cpan.org
=item *
Andrew Rodland arodland@cpan.org
=item *
Chris Prather chris@prather.org
=back
=head1 COPYRIGHT AND LICENCE
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.
=cut