File: Util.pm

package info (click to toggle)
libmeta-builder-perl 0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 128 kB
  • ctags: 38
  • sloc: perl: 495; makefile: 2
file content (54 lines) | stat: -rw-r--r-- 1,002 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package Meta::Builder::Util;
use strict;
use warnings;

sub import {
    my $class = shift;
    my $caller = caller;
    inject( $caller, "inject", \&inject );
}

sub inject {
    my ( $class, $sub, $code, $nowarn ) = @_;
    if ( $nowarn ) {
        no strict 'refs';
        no warnings 'redefine';
        *{"$class\::$sub"} = $code;
    }
    else {
        no strict 'refs';
        *{"$class\::$sub"} = $code;
    }
}

1;

__END__

=head1 NAME

Meta::Builder::Util - Utility functions for Meta::Builder

=head1 EXPORTS

=over 4

=item inject( $class, $name, $code, $redefine )

used to inject a sub into a namespace.

=back

=head1 AUTHORS

Chad Granum L<exodist7@gmail.com>

=head1 COPYRIGHT

Copyright (C) 2010 Chad Granum

Meta-Builder is free software; Standard perl licence.

Meta-Builder is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the license for more details.