in reply to Create Read-Accessors for a given hash

You can do so with operator overloading and tie-ing. Doing so will incur quite some overhead though. You can see the technique applied in MozRepl::RemoteObject, but I don't think the amount of code and the complexity don't warrant the tiny gains (if any).

package Getter; use overload '%{}' => 'Getter::as_hash', '@{}' => 'Getter::as_array', ; sub as_hash { my ($self) = @_; # return tied hash }; sub as_array { my ($self) = @_; # return tied array }; sub AUTOLOAD { # Map to hash access } package Getter::TiedArray; # Copy the code from MozRepl::RemoteObject and gut the remote function +ality package Getter::TiedHash; # Copy the code from MozRepl::RemoteObject and gut the remote function +ality