1 |
## --------------------------------------------------------------------------- |
2 |
## $Id: Symbol.pm,v 1.2 2003/03/27 15:17:03 joko Exp $ |
3 |
## --------------------------------------------------------------------------- |
4 |
## $Log: Symbol.pm,v $ |
5 |
## Revision 1.2 2003/03/27 15:17:03 joko |
6 |
## namespace fixes for Data::Mungle::* |
7 |
## |
8 |
## Revision 1.1 2003/01/22 17:59:22 root |
9 |
## + refactored from Mail::Audit::Dispatch |
10 |
## |
11 |
## --------------------------------------------------------------------------- |
12 |
|
13 |
|
14 |
=pod |
15 |
|
16 |
=head1 TODO |
17 |
|
18 |
o Investigate: Could this functionality be replaced through Perl's core/lib/Symbol.pm? |
19 |
|
20 |
|
21 |
=cut |
22 |
|
23 |
|
24 |
package Data::Mungle::Code::Symbol; |
25 |
|
26 |
use strict; |
27 |
use warnings; |
28 |
|
29 |
require Exporter; |
30 |
our @ISA = qw( Exporter ); |
31 |
our @EXPORT_OK = qw( |
32 |
export_symbols |
33 |
); |
34 |
|
35 |
|
36 |
use Data::Mungle::Code::Ref qw( get_coderef ); |
37 |
|
38 |
sub export_symbols { |
39 |
my $symbols = shift; |
40 |
my $mixinPackage = shift; |
41 |
my $callPackage = shift; |
42 |
$callPackage ||= __PACKAGE__; |
43 |
if (ref $symbols eq 'ARRAY') { |
44 |
foreach (@$symbols) { |
45 |
{ |
46 |
no strict 'refs'; |
47 |
my $newName = $mixinPackage . '::' . $_; |
48 |
*{$newName} = get_coderef($callPackage, $_); |
49 |
} |
50 |
} |
51 |
|
52 |
} elsif (ref $symbols eq 'HASH') { |
53 |
foreach (keys %$symbols) { |
54 |
{ |
55 |
no strict 'refs'; |
56 |
my $newName = $mixinPackage . '::' . $symbols->{$_}; |
57 |
*{$newName} = get_coderef($callPackage, $_); |
58 |
} |
59 |
} |
60 |
|
61 |
} |
62 |
} |
63 |
|
64 |
1; |