spiros has asked for the wisdom of the Perl Monks concerning the following question:
In order to keep things tidy, I created the 'name' and 'address' sub which effectively return the values:$self->{'data'}->{'name'} = 'spiros'; $self->{'data'}->{'address'} = 'london';
Is there a more 'elegant' or 'dynamic' way of doing so. Clearly this solution is not scalable in the event that the data structure has, say, 50 attributes since it requires manual declaration. May your life always be in the light. Thank you for your replies :)sub name { my $self = shift; return $self->{'data'}->{'name'}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: a simple matter of elegance
by lima1 (Curate) on Oct 03, 2007 at 10:27 UTC | |
|
Re: a simple matter of elegance
by merlyn (Sage) on Oct 03, 2007 at 11:06 UTC | |
by jdporter (Paladin) on Oct 03, 2007 at 13:35 UTC | |
|
Re: a simple matter of elegance
by grinder (Bishop) on Oct 03, 2007 at 11:02 UTC | |
|
Re: a simple matter of elegance
by andreas1234567 (Vicar) on Oct 03, 2007 at 10:30 UTC | |
|
Re: a simple matter of elegance
by Fletch (Bishop) on Oct 03, 2007 at 13:02 UTC | |
|
Re: a simple matter of elegance
by jeanluca (Deacon) on Oct 03, 2007 at 10:11 UTC | |
by spiros (Beadle) on Oct 03, 2007 at 10:15 UTC | |
by jeanluca (Deacon) on Oct 03, 2007 at 10:33 UTC | |
by perlfan (Parson) on Oct 03, 2007 at 13:08 UTC | |
|
Re: a simple matter of elegance
by snoopy (Curate) on Oct 03, 2007 at 22:58 UTC | |
|
Re: a simple matter of elegance
by dragonchild (Archbishop) on Oct 03, 2007 at 15:28 UTC | |
|
Re: a simple matter of elegance
by tfrayner (Curate) on Oct 04, 2007 at 08:04 UTC | |
|
Re: a simple matter of elegance
by frostman (Beadle) on Oct 05, 2007 at 00:44 UTC |