in reply to Re^2: Is this proof of concept too evil?
in thread Is this proof of concept too evil?
use Lexical::Alias qw( alias ); my ($ident, $value) = @_[0,1]; alias $_[1], $VALUES{ $ident ); $_[1] = $value if defined($value); splice(@_, 0, 2);
Update: It looks like Lexical::Alias can't alias a scalar to a hash element. It looks like you'll need to use tie as a fallback after all. Here's a slightly simpler version than what you had:
{ package My::Tie::Scalar::Alias; use strict; use warnings; use Tie::Scalar qw( ); our @ISA = 'Tie::Scalar'; sub TIESCALAR { my ($class, $ref) = @_; return bless $ref, $class; } sub FETCH { my $self = shift; return $$self; } sub STORE { my $self = shift; $$self = shift; } } tie $_[1], 'My::Tie::Scalar::Alias', \$VALUES{ $_[0] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Is this proof of concept too evil?
by exodist (Monk) on Jan 18, 2009 at 02:11 UTC | |
by ikegami (Patriarch) on Jan 18, 2009 at 02:23 UTC | |
by exodist (Monk) on Jan 18, 2009 at 07:31 UTC |