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

Re: a simple matter of elegance

by snoopy (Deacon)
on Oct 03, 2007 at 22:58 UTC ( #642530=note: print w/ replies, xml ) Need Help??

in reply to a simple matter of elegance

You could create closures for each of the attributes and add them to the package's namespace:

package Foo; use warnings; use strict; foreach my $att (qw/name address age sex geek_code/) { no strict 'refs'; *$att = sub { my $self = shift; return $self->{data}->{$att}; }; }

Comment on Re: a simple matter of elegance
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2015-08-01 01:02 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (285 votes), past polls