> I've been thinking about this for a couple days. The only problem I see
   > is that this doesn't allow me to do this:
   > 
   >    $oldpath = $tree->path('L','R') = 'R';
   >    @document = ($title, $junk, $r->xml_extract) = <STDIN>;
   > 
   > I would still have to use some yeechy combination with tie under your
   > RFC.

You can do this easily, even under Perl 5, with the Class::Proxy module:

        package Tree;
        use Class::Proxy;

        sub path {
                my ($self, @args) = @_;

                # walk down path to find referent:

                my $ref = $self;
                $ref = $ref->{$_} foreach (@_);

                # return a proxy for it,
                # with personalized assignment semantics:

                return proxy $ref,
                        STORE => { die unless $_[1] =~ /[LR]/; $_[0] = $_[1] };
        }

It isn't yet on the CPAN, but if people want it, I'll bump its priority
and get it out next week.

Damian

Reply via email to