Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: setting and retrieving sub-hash elements in an object

by Ven'Tatsu (Deacon)
on Dec 17, 2001 at 02:55 UTC ( [id://132409]=note: print w/replies, xml ) Need Help??


in reply to setting and retrieving sub-hash elements in an object

If you don't mind sacraficing compatability to do this than you can make your method 'lvalue'able. This only works with perl 5.6 and higher.
sub option : lvalue { shift->{options}->{shift()} }

Then you can get values as you normaly would and set values with
$object->option('new') = 'bar';

But if you do this please include use 5.6.0; at the top of your code.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-16 06:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found