Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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}; }; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2016-07-28 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (253 votes). Check out past polls.