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

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


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 :-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://642590]
[choroba]: Progress! Nowadays, you can write a Perl script to generate such an anagram!
[GotToBTru]: i like to order my chemicals a-la-carte ambrus ;)
[thepkd]: Hi, in trying to create an Array of Hash of Array of Hash. You read it right. Is it possible to dereference it without using temps?

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2016-12-06 13:09 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (104 votes). Check out past polls.