2 |
## $Id$ |
## $Id$ |
3 |
## --------------------------------------------------------------------------- |
## --------------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.4 2003/06/06 03:25:42 joko |
6 |
|
## + sub alias_simple |
7 |
|
## |
8 |
## Revision 1.3 2003/05/13 07:33:38 joko |
## Revision 1.3 2003/05/13 07:33:38 joko |
9 |
## enhanced: now can get symbols as list or hash |
## enhanced: now can get symbols as list or hash |
10 |
## |
## |
21 |
|
|
22 |
=head1 TODO |
=head1 TODO |
23 |
|
|
24 |
o Investigate: Could this functionality be replaced through Perl's core/lib/Symbol.pm? |
o Investigate: Could this functionality be completely replaced through CPAN's |
25 |
|
- Symbol.pm? |
26 |
|
- Alias.pm? |
27 |
|
|
28 |
|
|
29 |
=cut |
=cut |
38 |
our @ISA = qw( Exporter ); |
our @ISA = qw( Exporter ); |
39 |
our @EXPORT_OK = qw( |
our @EXPORT_OK = qw( |
40 |
export_symbols |
export_symbols |
41 |
|
alias_simple |
42 |
); |
); |
43 |
|
|
44 |
|
|
45 |
use Data::Mungle::Code::Ref qw( get_coderef ); |
use Data::Mungle::Code::Ref qw( get_coderef ); |
46 |
|
use Symbol; |
47 |
|
|
48 |
sub export_symbols { |
sub export_symbols { |
49 |
my $symbols = shift; |
my $symbols = shift; |
71 |
} |
} |
72 |
} |
} |
73 |
|
|
74 |
|
# Qualifies a variable identified by package name and variable |
75 |
|
# name into a valid symbol, resolves that symbol and stores the |
76 |
|
# result (a reference to this variable) into the designated target (slot). |
77 |
|
sub alias_simple { |
78 |
|
my $rule = shift; |
79 |
|
my $target = $rule->{slot}; |
80 |
|
my $name = $rule->{alias}; |
81 |
|
my $sym = qualify($rule->{var_name}, $rule->{var_pkg}); |
82 |
|
{ |
83 |
|
no strict 'refs'; |
84 |
|
$target->{$name} = ${$sym}; |
85 |
|
} |
86 |
|
} |
87 |
|
|
88 |
1; |
1; |
89 |
|
__END__ |