LogoopenSUSE Build Service > Projects
Sign Up | Log In

Keep imports out of your namespace

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),
      );
  }

Source Files (show merged sources derived from linked package)

Filename Size Changed Actions
cpanspec.yml 547 Bytes almost 3 years ago Download File
namespace-autoclean-0.28.tar.gz 35.3 KB over 2 years ago Download File
perl-namespace-autoclean.changes 4.14 KB over 2 years ago Download File
perl-namespace-autoclean.spec 2.87 KB over 2 years ago Download File

Comments for home:monitoringslm:perl (0)