Import namespace-clean-0.01.tar.gz.
[p5sagit/namespace-clean.git] / README
CommitLineData
40aef9d6 1NAME
2 namespace::clean - Keep imports out of your namespace
3
4VERSION
5 0.01
6
7SYNOPSIS
8 package Foo;
9 use warnings;
10 use strict;
11
12 use Carp qw(croak); # will be removed
13
14 sub bar { 23 } # will be removed
15
16 use namespace::clean;
17
18 sub baz { bar() } # still defined, 'bar' still bound
19
20 ### Will print:
21 # No
22 # No
23 # Yes
24 print +(__PACKAGE__->can('croak') ? 'Yes' : 'No'), "\n";
25 print +(__PACKAGE__->can('bar') ? 'Yes' : 'No'), "\n";
26 print +(__PACKAGE__->can('baz') ? 'Yes' : 'No'), "\n";
27
28 1;
29
30DESCRIPTION
31 When you define a function, or import one, into a Perl package, it will
32 naturally also be available as a method. This does not per se cause
33 problems, but it can complicate subclassing and, for example, plugin
34 classes that are included by loading them as base classes.
35
36 The "namespace::clean" pragma will remove all previously declared or
37 imported symbols at the end of the current package's compile cycle. This
38 means that functions are already bound by their name, and calls to them
39 still work. But they will not be available as methods on your class or
40 instances.
41
42METHODS
43 You shouldn't need to call any of these. Just "use" the package at the
44 appropriate place.
45
46 import
47 Makes a snapshot of the current defined functions and registers a
48 Filter::EOF cleanup routine to remove those symbols from the package at
49 the end of the compile-time.
50
51 get_functions
52 Takes a class as argument and returns all currently defined functions in
53 it as a hash reference with the function name as key and a typeglob
54 reference to the symbol as value.
55
56SEE ALSO
57 Filter::EOF
58
59AUTHOR AND COPYRIGHT
60 Robert 'phaylon' Sedlacek "<rs@474.at>", with many thanks to Matt S
61 Trout for the inspiration on the whole idea.
62
63LICENSE
64 This program is free software; you can redistribute it and/or modify it
65 under the same terms as perl itself.
66