Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: [Perl 6] Any provision for a "dereferencing object"?

by Joost (Canon)
on May 28, 2007 at 20:50 UTC ( #617881=note: print w/replies, xml ) Need Help??


in reply to [Perl 6] Any provision for a "dereferencing object"?

Interesting question. I don't know if there's any special construct in perl 6 to do this, but it's not THAT difficult to do something similar in perl 5:
#!/usr/bin/perl -w use strict; my %a; $a{foo}[1]{bar}{baz}[3] = "bla"; my $path = sub :lvalue { $_[0]->{foo}[1]{bar}{baz}[3] }; print $path->(\%a),"\n"; $path->(\%a) = "bar"; print $path->(\%a),"\n";
And you could extend this technique using closures to make the path dynamic.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://617881]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2021-05-10 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (106 votes). Check out past polls.

    Notices?