--- nfo/perl/libs/Data/Mungle/Code/Symbol.pm 2003/05/13 07:33:38 1.3 +++ nfo/perl/libs/Data/Mungle/Code/Symbol.pm 2003/06/06 03:25:42 1.4 @@ -1,7 +1,10 @@ ## --------------------------------------------------------------------------- -## $Id: Symbol.pm,v 1.3 2003/05/13 07:33:38 joko Exp $ +## $Id: Symbol.pm,v 1.4 2003/06/06 03:25:42 joko Exp $ ## --------------------------------------------------------------------------- ## $Log: Symbol.pm,v $ +## Revision 1.4 2003/06/06 03:25:42 joko +## + sub alias_simple +## ## Revision 1.3 2003/05/13 07:33:38 joko ## enhanced: now can get symbols as list or hash ## @@ -18,7 +21,9 @@ =head1 TODO - 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 + - Symbol.pm? + - Alias.pm? =cut @@ -33,10 +38,12 @@ our @ISA = qw( Exporter ); our @EXPORT_OK = qw( export_symbols + alias_simple ); use Data::Mungle::Code::Ref qw( get_coderef ); +use Symbol; sub export_symbols { my $symbols = shift; @@ -64,4 +71,19 @@ } } +# Qualifies a variable identified by package name and variable +# name into a valid symbol, resolves that symbol and stores the +# result (a reference to this variable) into the designated target (slot). +sub alias_simple { + my $rule = shift; + my $target = $rule->{slot}; + my $name = $rule->{alias}; + my $sym = qualify($rule->{var_name}, $rule->{var_pkg}); + { + no strict 'refs'; + $target->{$name} = ${$sym}; + } +} + 1; +__END__