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

Re: a simple matter of elegance

by tfrayner (Curate)
on Oct 04, 2007 at 08:04 UTC ( #642590=note: print w/ replies, xml ) Need Help??


in reply to a simple matter of elegance

Hi,

I've not seen this suggested yet:

{ no strict qw(refs); foreach my $method ( keys %{ $self->{'data'} } ) { *{$method} = sub { my ( $self ) = @_; return $self->{'data'}->{$method}; }; } }
I've used this a few times in the past to generate repetitive object accessors/mutators.

Cheers, Tim

Update: I beg your pardon, snoopy beat me to it :-)


Comment on Re: a simple matter of elegance
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (16)
As of 2014-10-20 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (85 votes), past polls