File Coverage

blib/lib/namespace/local.pm
Criterion Covered Total %
statement 228 229 99.5
branch 68 78 87.1
condition 37 54 68.5
subroutine 43 43 100.0
pod 1 1 100.0
total 377 405 93.0


line stmt bran cond sub pod time code
1 17     17   974217 use 5.008;
  17     8   202  
  8         578885  
  8         103  
2 17     17   107 use strict;
  17     8   35  
  17         493  
  8         46  
  8         15  
  8         225  
3 17     17   88 use warnings FATAL => 'all';
  17     8   37  
  17         1671  
  8         63  
  8         25  
  8         825  
4              
5             package namespace::local;
6              
7             our $VERSION = '0.08_01';
8              
9             =head1 NAME
10              
11             namespace::local - Confine imports or functions to a given scope
12              
13             =head1 SYNOPSIS
14              
15             This module allows to confine imports or private functions
16             to a given scope.
17              
18             package My::Module;
19              
20             sub normal_method {
21             # frobnicate; # nope!
22             };
23              
24             sub method_with_sugar {
25             use namespace::local;
26             use Crazy::Prototyped::DSL qw(do_this do_that frobnicate);
27              
28             do_this;
29             do_that;
30             frobnicate;
31             };
32              
33             sub another_method {
34             # frobnicate; # nope!
35             };
36              
37             The calling module's symbol table is saved at the C line
38             and restored upon leaving the block.
39              
40             The subsequent imports will do their job within the block,
41             but will not be available as methods at runtime.
42              
43             =head1 MODES OF OPERATION
44              
45             =head2 -around
46              
47             This confines all subsequent imports and functions
48             between the use of L and the end of scope.
49              
50             package My::Package;
51              
52             sub normal_sub {
53             # frobnicate() is unknown
54             }
55              
56             sub using_import {
57             use namespace::local -around;
58             use Some::Crazy::DSL qw(frobnicate);
59             frobnicate Foo => 42;
60             }
61              
62             sub no_import {
63             # frobnicate() is unknown
64             }
65              
66             =head2 -below (the default)
67              
68             Hides subsequent imports and functions on end of scope.
69              
70             This may be used to mask private functions:
71              
72             package My::Package;
73             use Moo::Role;
74              
75             # This is available everywhere
76             sub public {
77             return private();
78             };
79              
80             use namespace::local -below;
81              
82             # This is only available in the current file
83             sub private {
84             return 42;
85             };
86              
87             Note that this doesn't work for private I since methods
88             are resolved at runtime.
89              
90             =head2 -above
91              
92             Hide all functions and exports above the use line.
93              
94             This emulates L, by which this module is clearly inspired.
95              
96             package My::Module;
97             use POSIX;
98             use Time::HiRes;
99             use Carp;
100             use namespace::local -above;
101              
102             # now define public functions here
103              
104             =head2 no namespace::local
105              
106             Use C (C) to force end of scope for the latest
107             L instance in action:
108              
109             package My::Module;
110              
111             use namespace::local;
112             sub private { ... };
113             no namespace::local;
114              
115             # private not available here, even though the scope didn't end!
116              
117             No options are currently supported.
118              
119             =head1 OPTIONS
120              
121             Extra options may be passed to namespace::local:
122              
123             =head2 -target => Package::Name
124              
125             Act on another package instead of the caller.
126             Note that L is only meant to be used in BEGIN phase.
127              
128             =head2 -except => \@list
129              
130             Exempt symbols mentioned in list (with sigils)
131             from the module's action.
132              
133             No sigil means a function.
134             Only names made of word characters are supported.
135              
136             =head2 -except =>
137              
138             Exempt symbols with names matching the regular expression
139             from the module's action.
140              
141             Note that sigils are ignored here.
142              
143             =head2 -only => \@list
144              
145             Only affect the listed symbols (with sigils).
146             Rules are the same as for -except.
147              
148             =head2 -only =>
149              
150             Only affect symbols with matching names.
151              
152             All C<-only> and C<-except> options act together, further restricting the
153             set of affected symbols.
154              
155             =head1 EXEMPTIONS
156              
157             The following symbols are not touched by this module, to avoid breaking things:
158              
159             =over
160              
161             =item * anything that does not consist of word characters;
162              
163             =item * $_, @_, $1, $2, ...;
164              
165             =item * Arrays: C<@CARP_NOT>, C<@EXPORT>, C<@EXPORT_OK>, C<@ISA>;
166              
167             =item * Hashes: C<%OVERLOAD>;
168              
169             =item * Files: C, C, C, C;
170              
171             =item * Functions: C, C, C;
172              
173             =item * Scalars: C<$AUTOLOAD>, C<$a>, C<$b>;
174              
175             =back
176              
177             This list is likely incomplete, and may grow in the future.
178              
179             =head1 METHODS/FUNCTIONS
180              
181             None.
182              
183             =head1 CAVEATS
184              
185             This module is highly experimental.
186             The following two conditions are guaranteed to hold
187             at least until leaving the beta stage:
188              
189             =over
190              
191             =item * All symbols available before the use line will stay so
192             after end of scope
193              
194             =item * All I imported I below the use line
195             with names consisting of words and not present in L
196             are not going to be available after end of scope.
197              
198             =back
199              
200             The rest is a big grey zone.
201              
202             Currently the module works by saving and then restoring globs,
203             so variables and filehandles are also reset.
204             This may be changed in the future.
205              
206             Due to order of callback execution in L,
207             other modules in C namespace may interact poorly
208             with L.
209              
210             Up to v.0.07, C<-around> used to be the default mode instead of C<-below>.
211             C<-around> is much more restrictive, in particular, it prevents functions
212             defined below the block from propagating above the block.
213              
214             This is less of a problem than imported functions leaking upward.
215             No perfect solution has yet been found.
216              
217             =cut
218              
219 25     25   223 use Carp;
  25         68  
  25         1904  
220 25     25   11681 use B::Hooks::EndOfScope 'on_scope_end';
  25         283484  
  25         169  
221              
222             my @stack;
223              
224             sub import {
225 32     32   1978 my $class = shift;
226              
227 32         145 my $command = namespace::local::_command->new( caller => [ caller ] );
228 32         131 $command->parse_options( @_ );
229              
230             # on_scope_end executes multiple callbacks as FIFO
231             # we need reversed order, so use a stack of commands.
232 28 100       95 $stack[-1]->set_next( $command ) if @stack;
233 28         107 push @stack, $command;
234              
235 28         120 $command->prepare;
236              
237             on_scope_end {
238 28 100   28   1987 if (!$command->is_done) {
239 24         51 pop @stack; # make sure push == pop
240 24         70 local $Carp::Internal{'B::Hooks::EndOfScope::XS'} = 1;
241 24         61 local $Carp::Internal{'B::Hooks::EndOfScope'} = 1;
242 24         68 $command->execute;
243             };
244 28         183 };
245             };
246              
247             sub unimport {
248 2     2   124 my $class = shift;
249              
250 2 50       6 croak "No options supported for 'no namespace::local'"
251             if @_;
252              
253 2 50       5 croak "'no namespace::local' called but namespace::local isn't active"
254             unless @stack;
255              
256 2         4 my $command = pop @stack;
257 2         5 $command->execute;
258             };
259              
260             =head1 ENVIRONMENT
261              
262             Set C to see some debugging information
263             upon module load.
264              
265             =head1 THE INTERNALS
266              
267             A stack of "command" objects is used behind the scenes.
268              
269             Its interface is not public, see this module's source.
270              
271             Calling
272              
273             =over
274              
275             =item new
276              
277             =back
278              
279             on this package will create a command object,
280             I a C instance.
281              
282             The creation and destruction of command has no effect on the namespaces.
283              
284             Instead, special C and C methods
285             are called upon import and leaving scope, respectively.
286              
287             =cut
288              
289             sub new {
290 1     1 1 10 my $unused = shift;
291 1         4 namespace::local::_command->new(caller => [caller 0], @_);
292             };
293              
294             package
295             namespace::local::_command;
296              
297             # FIRST AND FOREMOST
298              
299             # See C for how perl stores the Symbol Tables.
300              
301             # In this module we use two-level hashrefs to represent the table:
302             # $table->{ $name }{ $type } = $reference
303             # where $name is a function/variable/whatever name,
304             # $type is one of ARRAY, CODE, FORMAT, HASH, IO, and SCALAR (see @TYPES below),
305             # and $reference is a reference of corresponding type (or undef).
306              
307             # So Foo::bar() would be represented as $table->{foo}{CODE}
308             # whereas @Foo::ISA is $table->{ISA}{ARRAY}.
309              
310 25     25   7945 use Carp;
  25         59  
  25         1471  
311 25     25   165 use Scalar::Util qw(blessed refaddr reftype);
  25         69  
  25         2166  
312             our @CARP_NOT = qw(namespace::local);
313              
314             # TODO need better env parsing...
315 25 100 100 25   168 use constant DEBUG => ( lc ($ENV{PERL_NAMESPACE_LOCAL} || '' ) eq 'debug' ? 1 : 0 );
  25         52  
  25         52051  
316              
317             ### Setup methods
318              
319             sub new {
320 33     33   648 my ($class, %opt) = @_;
321              
322             # TODO check options
323 33   50     174 $opt{caller} ||= [ caller 0 ];
324 33   33     302 $opt{except_rex} ||= qr/^[0-9]+$|^_$/; # no matter what, exempt $_, $1, ...
325 33   33     198 $opt{only_rex} ||= qr/^/; # match all
326 33   50     195 $opt{action} ||= '-below';
327 33   66     185 $opt{target} ||= $opt{caller}[0];
328 33   33     133 $opt{origin} ||= join ":", @{$opt{caller}}[1,2];
  33         181  
329              
330             # Skip some well-known variables and functions
331             # Format: touch_not{ $name }{ $type }
332             # NOTE if you change the list, also change the EXEMPTIONS section in the POD.
333 33         203 $opt{touch_not}{$_}{ARRAY}++ for qw( CARP_NOT EXPORT EXPORT_OK ISA );
334 33         138 $opt{touch_not}{$_}{CODE}++ for qw( AUTOLOAD DESTROY import );
335 33         114 $opt{touch_not}{$_}{HASH}++ for qw( OVERLOAD );
336 33         182 $opt{touch_not}{$_}{IO}++ for qw( DATA STDERR STDIN STDOUT );
337 33         143 $opt{touch_not}{$_}{SCALAR}++ for qw( AUTOLOAD a b );
338              
339 33         104 return bless \%opt, $class;
340             };
341              
342             sub set_next {
343 5     5   11 my ($self, $next) = @_;
344              
345             carp "probably a bug in namespace::local - uncommitted command replaced in chain"
346 5 50 66     23 if $self->{next} and !$self->{next}{done};
347              
348 5         10 $self->{next} = $next;
349             };
350              
351             sub is_done {
352 28     28   118 return $_[0]->{done};
353             };
354              
355             sub DESTROY {
356 5     5   4503 my $self = shift;
357             carp "probably a bug in namespace::local: callback set at $self->{origin} but never executed"
358 5 50 33     211 if $self->{todo} and !$self->{done};
359             };
360              
361             my %known_action;
362             $known_action{$_}++ for qw(-above -below -around);
363              
364             # This changes nothing except the object itself
365             # input is the same as that of namespace::local->import
366             sub parse_options {
367 32     32   58 my $self = shift;
368              
369             # wrote a Getopt::Long from scratch...
370 32         98 while (@_) {
371 27         52 my $arg = shift;
372 27 100       206 if ( $known_action{$arg} ) {
    100          
    100          
    100          
373 15         147 $self->{action} = $arg;
374             } elsif ($arg eq '-target') {
375 2         17 $self->{target} = shift;
376             } elsif ($arg eq '-except') {
377 5         16 my $cond = shift;
378 5 100       21 if (ref $cond eq 'Regexp') {
    100          
379 1         33 $self->{except_rex} = qr((?:$self->{except_rex})|(?:$cond));
380             } elsif (ref $cond eq 'ARRAY') {
381 3         11 $self->touch_not( @$cond );
382             } else {
383 1         2 _croak( "-except argument must be regexp or array" )
384             };
385             } elsif ($arg eq '-only') {
386 4         17 my $cond = shift;
387 4 100       20 if (ref $cond eq 'Regexp') {
    100          
388 2         13 $self->{only_rex} = $cond;
389             } elsif (ref $cond eq 'ARRAY') {
390 1         3 $self->restrict( @$cond );
391             } else {
392 1         2 _croak( "-only argument must be regexp or array" )
393             };
394             } else {
395 1         6 _croak( "unknown option $arg" );
396             };
397             };
398             };
399              
400             sub touch_not {
401 3     3   9 my ($self, @list) = @_;
402              
403 3         10 foreach (sigil_to_type(@list)) {
404 3         24 $self->{touch_not}{ $_->[0] }{ $_->[1] }++
405             };
406             };
407              
408             sub restrict {
409 1     1   3 my ($self, @list) = @_;
410              
411 1         4 foreach (sigil_to_type(@list)) {
412 2         15 $self->{restrict_symbols}{ $_->[0] }{ $_->[1] }++
413             };
414             };
415              
416             # TODO join with @TYPES array from below
417             my %sigil = (
418             '' => 'CODE',
419             '$' => 'SCALAR',
420             '%' => 'HASH',
421             '@' => 'ARRAY',
422             );
423              
424             # returns [ name, type ] for each argument
425             sub sigil_to_type {
426             map {
427 4 100   4   11 /^([\$\@\%]?)(\w+)$/
  6         40  
428             or _croak( "cannot exempt sybmol $_: unsupported format" );
429 5         28 [ $2, $sigil{$1} ]
430             } @_;
431             };
432              
433             ### Command pattern split into prepare + execute
434              
435             # input: none
436             # output: none
437             # side effects: modify target package + setup callback for self->execute
438             sub prepare {
439 28     28   47 my $self = shift;
440              
441 28         94 my $action = $self->{action};
442              
443 28         100 my $table = $self->read_symbols;
444              
445 28 100       128 if ($action eq '-around') {
    100          
446             # Overwrite symbol table with a copy of itself.
447             # Somehow this triggers binding of symbols in the code
448             # that was parsed so far (i.e. above the 'use' line)
449             # and undefined symbols (in that area) remain so forever
450 4         11 $self->write_symbols( $table );
451             } elsif ( $action eq '-below' ) {
452             # Stabilize known functions, leave everything else as is
453 17         49 my $func = $self->filter_functions( $table );
454 17         48 $self->write_symbols( $func );
455             };
456              
457 28 100       98 if ($action eq '-above' ) {
458             $self->{todo} = sub {
459 7     7   22 $self->erase_only_symbols( $table );
460 7         42 };
461             } else {
462             $self->{todo} = sub {
463 21     21   76 $self->replace_symbols( undef, $table );
464 21         145 };
465             };
466             };
467              
468             # input: none
469             # output: none
470             # side effect: modify target package
471             sub execute {
472 29     29   77 my ($self) = @_;
473              
474             # always execute stacked commands in reverse order
475             $self->{next}->execute
476 29 100       96 if $self->{next};
477              
478             $self->{todo}->()
479 29 100       140 unless $self->{done}++;
480             };
481              
482             ### High-level effectful functions
483              
484             # Don't ever touch NAME, PACKAGE, and GLOB that are also known to Perl
485             my @TYPES = qw(SCALAR ARRAY HASH CODE IO FORMAT);
486              
487             # In: symbol table hashref
488             # Out: side effect
489             sub erase_only_symbols {
490 7     7   13 my ($self, $table) = @_;
491              
492 7         15 my $package = $self->{target};
493 7         25 my @list = keys %$table;
494              
495             # load all necessary symbols
496 7         24 my $current = $self->read_symbols( \@list );
497              
498             # filter out what we were going to delete
499 7         16 foreach my $name ( @list ) {
500             $table->{$name}{$_} and delete $current->{$name}{$_}
501 13   66     107 for @TYPES;
502             };
503              
504             # put it back in place
505 7         23 $self->replace_symbols( \@list, $current );
506             };
507              
508             # This method's signature is a bit counterintuitive:
509             # $self->replace_symbols( \@names_to_erase, \%new_table_entries )
510             # If first argument is omitted, the whole namespace is scanned instead.
511             # Separate erase_symbols and write_symbols turned out to be cumbersome
512             # because of the need to handle granular exclusion list.
513             # This method can fill both roles.
514             # Providing an empty list would make it just write the symbol table,
515             # whereas an empty hash would mean deletion only.
516             sub replace_symbols {
517 30     30   2130 my ($self, $clear_list, $table) = @_;
518              
519 30   100     154 $clear_list ||= [ $self->read_names ];
520 30   100     100 $table ||= {};
521              
522 30         63 my %uniq;
523 30         263 $uniq{$_}++ for keys %$table, @$clear_list;
524              
525             # re-read the symbol table
526 30         194 my $old_table = $self->read_symbols( [ keys %uniq ] );
527              
528             # create a plan for change
529 30         147 my $diff = $self->table_diff( $old_table, $table );
530 30 50       135 return unless keys %$diff;
531              
532 30         101 $self->write_symbols( $diff );
533             };
534              
535             sub filter_functions {
536 17     17   35 my ($self, $table) = @_;
537              
538 17         30 my %new_table;
539              
540 17         60 foreach (keys %$table) {
541             $new_table{$_} = $table->{$_}
542 165 100       348 if defined $table->{$_}{CODE};
543             };
544              
545 17         44 return \%new_table;
546             };
547              
548             # Oddly enough, pure
549             # In: old and new two symbol table hashrefs
550             # Out: part of new table that differs from the old,
551             # with touch_not rules applied
552             sub table_diff {
553 30     30   80 my ($self, $old_table, $new_table) = @_;
554              
555 30         71 my %uniq_name;
556 30         293 $uniq_name{$_}++ for keys %$old_table, keys %$new_table;
557              
558 30         90 my $touch_not = $self->{touch_not};
559              
560 30 100       101 if (my $restrict = $self->{restrict_symbols}) {
561             # If a restriction is in place, invert it and merge into skip
562             # TODO write this better
563             # TODO does it really belong here?
564 1   33     4 $restrict->{$_} or delete $uniq_name{$_} for keys %uniq_name;
565 1         2 my %real_touch_not;
566 1         2 foreach my $name (keys %uniq_name) {
567             # 2 levels of shallow copy is enough
568 2         3 foreach my $type( @TYPES ) {
569             $real_touch_not{$name}{$type}++
570 12 100 66     38 unless $restrict->{$name}{$type} and not $touch_not->{$name}{$type};
571             };
572             };
573 1         2 $touch_not = \%real_touch_not;
574             };
575              
576 30         61 my $diff;
577              
578             # iterate over keys of both, 2 levels deep
579 30         185 foreach my $name (sort keys %uniq_name) {
580 268   50     569 my $old = $old_table->{$name} || {};
581 268   100     584 my $new = $new_table->{$name} || {};
582 268   100     797 my $skip = $touch_not->{$name} || {};
583              
584 268         405 my %uniq_type;
585 268         1014 $uniq_type{$_}++ for keys %$old, keys %$new;
586              
587 268         670 foreach my $type (sort keys %uniq_type) {
588 492 100       900 next if $skip->{$type};
589              
590 467 100       995 if (ref $old->{$type} ne ref $new->{$type}) {
591             # As nonrefs are not allowed here,
592             # this also handles undef vs. defined case
593 71         148 $diff->{$name}{$type} = $new->{$type};
594 71         153 next;
595             };
596              
597             # both undef, nothing to see here
598 396 50       674 next unless ref $new->{$type};
599              
600             # pointing to different things
601 396 100       1082 if (refaddr $old->{$type} != refaddr $new->{$type}) {
602 4         10 $diff->{$name}{$type} = $new->{$type};
603 4         27 next;
604             };
605             };
606              
607 268 100       649 if ($diff->{$name}) {
608             # if we cannot avoid overwriting,
609             # make sure to copy ALL skipped values we know of
610 53         145 $diff->{$name}{$_} = $old->{$_} for keys %$skip;
611              
612             # removing a scalar copletely didn't work very well on Perl 5.10.1,
613             # causing segfaults in unrelated places.
614 53   100     305 $diff->{$name}{SCALAR} ||= \undef;
615             };
616             };
617              
618 30         121 return $diff;
619             };
620              
621             ### Low-level symbol-table read & write
622             ### no magic should happen above this line
623              
624             # NOTE that even here we are in full strict mode
625             # The pattern for working with raw data is this:
626             # my $value = do { no strict 'refs'; ... }; ## no critic
627              
628             # in: none
629             # out: sorted & filtered list of symbols
630             sub read_names {
631 53     53   95 my $self = shift;
632              
633 53         87 my $package = $self->{target};
634 53         86 my $except = $self->{except_rex};
635 53         81 my $only = $self->{only_rex};
636              
637             my @list = sort grep {
638 2155 100 100     8848 /^\w+$/ and $_ !~ $except and $_ =~ $only
639 53         88 } do {
640 25     25   233 no strict 'refs'; ## no critic
  25         59  
  25         3912  
641 53         85 keys %{ $package."::" };
  53         851  
642             };
643              
644 53         486 return @list;
645             };
646              
647             # In: symbol list arrayref (read_symbols if none)
648             # Out: symbol table hashref
649             sub read_symbols {
650 69     69   149 my ($self, $list) = @_;
651              
652 69         127 my $package = $self->{target};
653 69   100     296 $list ||= [ $self->read_names ];
654 4         8 $list = [ grep { $self->{restrict_symbols}{$_} } @$list ]
655 69 100       179 if $self->{restrict_symbols};
656              
657 69         108 my %content;
658 69         135 foreach my $name ( @$list ) {
659 528         757 foreach my $type (@TYPES) {
660 3168         3883 my $value = do {
661 25     25   229 no strict 'refs'; ## no critic
  25         57  
  25         5503  
662 3168         3734 *{$package."::".$name}{$type};
  3168         6145  
663             };
664 3168 100       6608 $content{$name}{$type} = $value if defined $value;
665             };
666             };
667              
668 69         236 return \%content;
669             };
670              
671             # writes raw symbols, ignoring touch_not!
672             # In: symbol table hashref
673             # Out: none
674             sub write_symbols {
675 51     51   103 my ($self, $table) = @_;
676              
677 51         98 my $package = $self->{target};
678              
679 51         82 if (DEBUG) {
680             my $old_table = $self->read_symbols;
681             $self->message( "package $self->{target} to be altered: ".dump_table($table, $old_table) )
682             };
683              
684              
685 51         135 foreach my $name( keys %$table ) {
686 212         317 my $copy = $table->{$name};
687              
688             {
689 25     25   198 no strict 'refs'; ## no critic
  25         77  
  25         1642  
  212         1724  
690 212         261 delete ${ $package."::" }{$name};
  212         663  
691             };
692              
693 212         499 foreach my $type ( keys %$copy ) {
694 406 100       905 ref $copy->{$type} or next;
695             eval {
696             # FIXME on perls 5.014..5.022 this block fails
697             # because @ISA is readonly.
698             # So we wrap it in eval with no catch
699             # until a better solution is done
700 25     25   190 no strict 'refs'; ## no critic
  25         55  
  25         13681  
701 374         538 *{ $package."::".$name } = $copy->{$type};
  372         1078  
702 372         1250 1;
703 371 50       510 } || do {
704 4         16 carp "namespace::local: failed to write $package :: $name ($type), but trying to continue: $@";
705             };
706             };
707             };
708             };
709              
710             ### Logging
711              
712             sub dump_table {
713 7     3   31 my ($table, $old_table) = @_;
714              
715 3         3 my @out;
716 3         11 foreach my $name( sort keys %$table ) {
717 3         7 my $glob = $table->{$name};
718 3         9 foreach my $type( sort keys %$glob ) {
719             push @out, "*$name\{$type\}=".(
720             $old_table
721             ? _is_and_was( $glob->{$type}, $old_table->{$name}{$type} )
722 6 50       24 : _ref2str( $glob->{$type} )
723             );
724             };
725             };
726              
727 3         16 return join ", ", @out;
728             };
729              
730             sub _is_and_was {
731 6     6   14 my ($new, $old) = @_;
732              
733 6 50 100     58 if ((refaddr $new || 0) != (refaddr $old || 0)) {
      100        
734 6         14 return _ref2str( $new )."[was: "._ref2str( $old )."]";
735             } else {
736 0         0 return _ref2str( $new )."[unchanged]";
737             };
738             };
739              
740             # TODO find existing?
741             sub _ref2str {
742 12     12   20 my $ref = shift;
743              
744 12 50       74 return ref $ref
    100          
745             ? blessed $ref
746             ? sprintf "%s=%s(0x%x)", ref $ref, reftype $ref, refaddr $ref
747             : sprintf "%s(0x%x)", ref $ref, refaddr $ref
748             : 'undef';
749             };
750              
751             sub message {
752 3     3   7 my ($self, $msg) = @_;
753              
754 3         7 $msg =~ s/\n$//s;
755 3         423 carp "$msg via namespace::local from $self->{origin}";
756             };
757              
758             sub _croak {
759 4     4   51 croak ("namespace::local: ".shift);
760             };
761              
762             =head1 BUGS
763              
764             As of 0.0604, C<-around> hides subroutines defined below its scope end
765             from anything above it.
766             No solution exists so far.
767              
768             This is experimental module. There certainly are more bugs.
769              
770             Bug reports, feature requests, suggestions and general feedback welcome at:
771              
772             =over
773              
774             =item * L
775              
776             =item * L
777              
778             =item * C
779              
780             =back
781              
782             =head1 SUPPORT
783              
784             You can find documentation for this module with the C command.
785              
786             perldoc namespace::local
787              
788             You can also look for information at:
789              
790             =over
791              
792             =item * github:
793              
794             L
795              
796             =item * RT: CPAN's request tracker (report bugs here)
797              
798             L
799              
800             =item * AnnoCPAN: Annotated CPAN documentation
801              
802             L
803              
804             =item * CPAN Ratings
805              
806             L
807              
808             =item * Search CPAN
809              
810             L
811              
812             =back
813              
814             =head1 SEE ALSO
815              
816             L gave the inspiration for this module.
817              
818             L, L and probably more also clean
819             caller's namespace, but differently.
820              
821             L is used as a backend.
822              
823             L explains how reading/writing the namespace works.
824              
825             =head1 LICENSE AND COPYRIGHT
826              
827             Copyright 2018 Konstantin S. Uvarin, C<< >>
828              
829             This program is free software; you can redistribute it and/or modify it
830             under the terms of the the Artistic License (2.0). You may obtain a
831             copy of the full license at:
832              
833             L
834              
835             Any use, modification, and distribution of the Standard or Modified
836             Versions is governed by this Artistic License. By using, modifying or
837             distributing the Package, you accept this license. Do not use, modify,
838             or distribute the Package, if you do not accept this license.
839              
840             If your Modified Version has been derived from a Modified Version made
841             by someone other than you, you are nevertheless required to ensure that
842             your Modified Version complies with the requirements of this license.
843              
844             This license does not grant you the right to use any trademark, service
845             mark, tradename, or logo of the Copyright Holder.
846              
847             This license includes the non-exclusive, worldwide, free-of-charge
848             patent license to make, have made, use, offer to sell, sell, import and
849             otherwise transfer the Package with respect to any patent claims
850             licensable by the Copyright Holder that are necessarily infringed by the
851             Package. If you institute patent litigation (including a cross-claim or
852             counterclaim) against any party alleging that the Package constitutes
853             direct or contributory patent infringement, then this Artistic License
854             to you shall terminate on the date that such litigation is filed.
855              
856             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
857             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
858             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
859             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
860             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
861             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
862             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
863             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
864              
865              
866             =cut
867              
868             1; # End of namespace::local
869