in reply to Re: (tye)Re: Aliasing Variables
in thread Aliasing Variables
No XS here, works fine with 5.x, but maybe a little slow :)package alias; use strict; BEGIN { use base qw(Exporter); @alias::EXPORT = qw(make_alias); } sub make_alias { tie $_[0], __PACKAGE__, \$_[1]; } sub TIESCALAR { my($class, $target_ref) = @_; bless $target_ref, $class; } sub STORE { my $self = shift; $$self = shift; } sub FETCH { my $self = shift; $$self; } 1;
use alias; my $self = { x => 1 }; make_alias my $x, $self->{x}; $x = 100; print $self->{x}; # 100
--
Tatsuhiko Miyagawa
miyagawa@cpan.org
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: (tye)Re: Aliasing Variables
by John M. Dlugosz (Monsignor) on Jul 22, 2001 at 22:11 UTC | |
by miyagawa (Chaplain) on Jul 23, 2001 at 09:50 UTC | |
by John M. Dlugosz (Monsignor) on Jul 23, 2001 at 23:49 UTC |